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

Commit 428fab2

Browse files
committed
Cleanup HideAndDontSave detection and support
1 parent 760b298 commit 428fab2

File tree

5 files changed

+392
-410
lines changed

5 files changed

+392
-410
lines changed

src/Core/SceneHandler.cs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,7 @@ internal static GameObject DontDestroyMe
8282
}
8383
private static GameObject dontDestroyObject;
8484

85-
public static bool InspectingAssetScene => SelectedScene == AssetScene;
86-
87-
internal static Scene AssetScene => AssetObject.scene;
88-
internal static int AssetHandle => AssetScene.handle;
89-
90-
internal static GameObject AssetObject
91-
{
92-
get
93-
{
94-
if (!assetObject)
95-
{
96-
assetObject = RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(GameObject))
97-
.First(it => !it.TryCast<GameObject>().scene.IsValid())
98-
.TryCast<GameObject>();
99-
}
100-
return assetObject;
101-
}
102-
}
103-
private static GameObject assetObject;
85+
public static bool InspectingAssetScene => !SelectedScene?.IsValid() ?? false;
10486

10587
internal static void Init()
10688
{
@@ -122,7 +104,7 @@ internal static void Init()
122104
catch (Exception ex)
123105
{
124106
gotAllScenesInBuild = false;
125-
ExplorerCore.Log($"Unable to generate list of all Scenes in the build: {ex}");
107+
ExplorerCore.LogWarning($"Unable to generate list of all Scenes in the build: {ex}");
126108
}
127109
}
128110

@@ -131,7 +113,7 @@ internal static void Update()
131113
int curHandle = SelectedScene?.handle ?? -1;
132114
// DontDestroyOnLoad always exists, so default to true if our curHandle is that handle.
133115
// otherwise we will check while iterating.
134-
bool inspectedExists = curHandle == DontDestroyHandle || curHandle == AssetHandle;
116+
bool inspectedExists = curHandle == DontDestroyHandle || curHandle == 0;
135117

136118
// Quick sanity check if the loaded scenes changed
137119
bool anyChange = LoadedSceneCount != allLoadedScenes.Count;
@@ -145,7 +127,7 @@ internal static void Update()
145127
for (int i = 0; i < SceneManager.sceneCount; i++)
146128
{
147129
Scene scene = SceneManager.GetSceneAt(i);
148-
if (scene == default || scene.handle == -1 || !scene.isLoaded)
130+
if (scene == default || !scene.isLoaded)
149131
continue;
150132

151133
// If no changes yet, ensure the previous list contained this handle.
@@ -161,7 +143,7 @@ internal static void Update()
161143

162144
// Always add the DontDestroyOnLoad scene and the "none" scene.
163145
allLoadedScenes.Add(DontDestroyScene);
164-
allLoadedScenes.Add(AssetScene);
146+
allLoadedScenes.Add(default);
165147

166148
// Default to first scene if none selected or previous selection no longer exists.
167149
if (!inspectedExists)

src/ExplorerCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace UnityExplorer
1919
public static class ExplorerCore
2020
{
2121
public const string NAME = "UnityExplorer";
22-
public const string VERSION = "4.0.3";
22+
public const string VERSION = "4.0.4";
2323
public const string AUTHOR = "Sinai";
2424
public const string GUID = "com.sinai.unityexplorer";
2525

src/UI/ObjectExplorer/SearchProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ private static bool Filter(Scene scene, SceneFilter filter)
4545
case SceneFilter.DontDestroyOnLoad:
4646
return scene == SceneHandler.DontDestroyScene;
4747
case SceneFilter.HideAndDontSave:
48-
return scene == SceneHandler.AssetScene;
48+
return scene == default;
4949
case SceneFilter.ActivelyLoaded:
50-
return scene != SceneHandler.DontDestroyScene && scene != SceneHandler.AssetScene;
50+
return scene != SceneHandler.DontDestroyScene && scene != default;
5151
default:
5252
return false;
5353
}

0 commit comments

Comments
 (0)