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

Commit 36fc17a

Browse files
committed
Get rid of pointless ReadOnlyCollection properties
1 parent adfa29e commit 36fc17a

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/ObjectExplorer/SceneHandler.cs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ internal set
2929
/// <summary>
3030
/// The GameObjects in the currently inspected scene.
3131
/// </summary>
32-
public static ReadOnlyCollection<GameObject> CurrentRootObjects => new ReadOnlyCollection<GameObject>(rootObjects);
33-
private static GameObject[] rootObjects = new GameObject[0];
32+
public static GameObject[] CurrentRootObjects { get; private set; } = new GameObject[0];
3433

3534
/// <summary>
3635
/// All currently loaded Scenes.
3736
/// </summary>
38-
public static ReadOnlyCollection<Scene> LoadedScenes => new ReadOnlyCollection<Scene>(allLoadedScenes);
39-
private static readonly List<Scene> allLoadedScenes = new List<Scene>();
37+
public static List<Scene> LoadedScenes { get; private set; } = new List<Scene>();
4038
private static HashSet<Scene> previousLoadedScenes;
4139

4240
/// <summary>
@@ -59,7 +57,7 @@ internal set
5957
/// <summary>
6058
/// Invoked whenever the list of currently loaded Scenes changes. The argument contains all loaded scenes after the change.
6159
/// </summary>
62-
public static event Action<ReadOnlyCollection<Scene>> OnLoadedScenesChanged;
60+
public static event Action<List<Scene>> OnLoadedScenesChanged;
6361

6462
/// <summary>
6563
/// Equivalent to <see cref="SceneManager.sceneCount"/> + 2, to include 'DontDestroyOnLoad' and the 'None' scene.
@@ -115,7 +113,7 @@ internal static void Update()
115113
int confirmedCount = 2;
116114
bool inspectedExists = SelectedScene == DontDestroyScene || (SelectedScene.HasValue && SelectedScene.Value == default);
117115

118-
allLoadedScenes.Clear();
116+
LoadedScenes.Clear();
119117

120118
for (int i = 0; i < SceneManager.sceneCount; i++)
121119
{
@@ -131,30 +129,26 @@ internal static void Update()
131129
if (!inspectedExists && scene == SelectedScene)
132130
inspectedExists = true;
133131

134-
allLoadedScenes.Add(scene);
132+
LoadedScenes.Add(scene);
135133
}
136134

137-
bool anyChange = confirmedCount != allLoadedScenes.Count;
135+
bool anyChange = confirmedCount != LoadedScenes.Count;
138136

139-
allLoadedScenes.Add(DontDestroyScene);
140-
allLoadedScenes.Add(default);
141-
previousLoadedScenes = new HashSet<Scene>(allLoadedScenes);
137+
LoadedScenes.Add(DontDestroyScene);
138+
LoadedScenes.Add(default);
139+
previousLoadedScenes = new HashSet<Scene>(LoadedScenes);
142140

143141
// Default to first scene if none selected or previous selection no longer exists.
144142
if (!inspectedExists)
145-
{
146-
SelectedScene = allLoadedScenes.First();
147-
}
143+
SelectedScene = LoadedScenes.First();
148144

149145
// Notify on the list changing at all
150146
if (anyChange)
151-
{
152147
OnLoadedScenesChanged?.Invoke(LoadedScenes);
153-
}
154148

155149
// Finally, update the root objects list.
156150
if (SelectedScene != null && ((Scene)SelectedScene).IsValid())
157-
rootObjects = RuntimeProvider.Instance.GetRootGameObjects((Scene)SelectedScene);
151+
CurrentRootObjects = RuntimeProvider.Instance.GetRootGameObjects((Scene)SelectedScene);
158152
else
159153
{
160154
var allObjects = RuntimeProvider.Instance.FindObjectsOfTypeAll(typeof(GameObject));
@@ -165,7 +159,7 @@ internal static void Update()
165159
if (go.transform.parent == null && !go.scene.IsValid())
166160
objects.Add(go);
167161
}
168-
rootObjects = objects.ToArray();
162+
CurrentRootObjects = objects.ToArray();
169163
}
170164
}
171165
}

0 commit comments

Comments
 (0)