Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
Fix FPS drop with MelonLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
sinai-dev committed Dec 28, 2021
1 parent 0050cff commit 0dd1934
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ExplorerCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace UnityExplorer
public static class ExplorerCore
{
public const string NAME = "UnityExplorer";
public const string VERSION = "4.4.1";
public const string VERSION = "4.4.2";
public const string AUTHOR = "Sinai";
public const string GUID = "com.sinai.unityexplorer";

Expand Down
16 changes: 16 additions & 0 deletions src/ObjectExplorer/SceneExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using UnityExplorer.UI.Widgets;
using UniverseLib.UI;
using UniverseLib;
using System.Collections;

namespace UnityExplorer.ObjectExplorer
{
Expand Down Expand Up @@ -254,6 +255,21 @@ public override void ConstructUI(GameObject content)
// Scene Loader

ConstructSceneLoader();

RuntimeProvider.Instance.StartCoroutine(TempFixCoro());
}

// To "fix" a strange FPS drop issue with MelonLoader.
private IEnumerator TempFixCoro()
{
float start = Time.realtimeSinceStartup;

while (Time.realtimeSinceStartup - start < 2.5f)
yield return null;

// Select "HideAndDontSave" and then go back to first scene.
this.sceneDropdown.value = sceneDropdown.options.Count - 1;
this.sceneDropdown.value = 0;
}

private const string DEFAULT_LOAD_TEXT = "[Select a scene]";
Expand Down
5 changes: 3 additions & 2 deletions src/ObjectExplorer/SceneHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ internal static void Update()
LoadedScenes.Add(scene);
}

bool anyChange = confirmedCount != LoadedScenes.Count;

LoadedScenes.Add(DontDestroyScene);
LoadedScenes.Add(default);

bool anyChange = confirmedCount != LoadedScenes.Count;

previousLoadedScenes = new HashSet<Scene>(LoadedScenes);

// Default to first scene if none selected or previous selection no longer exists.
Expand Down

0 comments on commit 0dd1934

Please sign in to comment.