Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ObjectExplorer/SceneExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void JumpToTransform(Transform transform)
if (SceneHandler.SelectedScene != go.scene)
{
int idx;
if (go.scene == default || go.scene.handle == -1)
if (go.scene == default || go.scene.name == "DontDestroyOnLoad") //scene.handle no longer exists in Unity 6
idx = sceneDropdown.options.Count - 1;
else
idx = sceneDropdown.options.IndexOf(sceneToDropdownOption[go.scene]);
Expand Down
23 changes: 17 additions & 6 deletions src/ObjectExplorer/SceneHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,21 @@ internal set
/// <summary>Whether or not the "DontDestroyOnLoad" scene exists in this game.</summary>
public static bool DontDestroyExists { get; private set; }

private static bool DoesDontDestroyOnLoadExist()
{
for (int i = 0; i < SceneManager.sceneCount; i++)
{
Scene scene = SceneManager.GetSceneAt(i);
if (scene.name == "DontDestroyOnLoad")
return true;
}
return false;
}

internal static void Init()
{
// Check if the game has "DontDestroyOnLoad"
DontDestroyExists = Scene.GetNameInternal(-12) == "DontDestroyOnLoad";
DontDestroyExists = DoesDontDestroyOnLoadExist();

// Try to get all scenes in the build settings. This may not work.
try
Expand Down Expand Up @@ -80,8 +91,8 @@ internal static void Update()
// Inspected scene will exist if it's DontDestroyOnLoad or HideAndDontSave
bool inspectedExists =
SelectedScene.HasValue
&& ((DontDestroyExists && SelectedScene.Value.handle == -12)
|| SelectedScene.Value.handle == -1);
&& ((DontDestroyExists && SelectedScene.Value.name == "DontDestroyOnLoad")
|| !SelectedScene.Value.IsValid());

LoadedScenes.Clear();

Expand All @@ -98,9 +109,9 @@ internal static void Update()
LoadedScenes.Add(scene);
}

if (DontDestroyExists)
LoadedScenes.Add(new Scene { m_Handle = -12 });
LoadedScenes.Add(new Scene { m_Handle = -1 });
//if (DontDestroyExists)
// LoadedScenes.Add(new Scene { m_Handle = -12 });
//LoadedScenes.Add(new Scene { m_Handle = -1 });

// Default to first scene if none selected or previous selection no longer exists.
if (!inspectedExists)
Expand Down
2 changes: 1 addition & 1 deletion src/ObjectExplorer/SearchProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static bool Filter(Scene scene, SceneFilter filter)
return filter switch
{
SceneFilter.Any => true,
SceneFilter.DontDestroyOnLoad => scene.handle == -12,
SceneFilter.DontDestroyOnLoad => scene.name == "DontDestroyOnLoad", //Scene.handle no longer exists in Unity 6
SceneFilter.HideAndDontSave => scene == default,
SceneFilter.ActivelyLoaded => scene.buildIndex != -1,
_ => false,
Expand Down
5 changes: 0 additions & 5 deletions src/UI/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,16 @@ public static void Update()
{
if (!UIRoot)
return;

// If we are doing a Mouse Inspect, we don't need to update anything else.
if (MouseInspector.Instance.TryUpdate())
return;

// Update Notification modal
Notification.Update();

// Check forceUnlockMouse toggle
if (IInputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value))
UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = !UniverseLib.Config.ConfigManager.Force_Unlock_Mouse;

// update the timescale value
timeScaleWidget.Update();

// check screen dimension change
Display display = DisplayManager.ActiveDisplay;
if (display.renderingWidth != lastScreenWidth || display.renderingHeight != lastScreenHeight)
Expand Down
18 changes: 14 additions & 4 deletions src/UI/Widgets/GameObjects/GameObjectInfoPanel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityExplorer.UI.Panels;
using UnityEngine.SceneManagement;
using UnityExplorer.UI.Panels;
using UniverseLib.UI;
using UniverseLib.UI.Models;

Expand All @@ -12,7 +13,7 @@ public class GameObjectInfoPanel
string lastGoName;
string lastPath;
bool lastParentState;
int lastSceneHandle;
string lastSceneId;
string lastTag;
int lastLayer;
int lastFlags;
Expand Down Expand Up @@ -40,7 +41,16 @@ public GameObjectInfoPanel(GameObjectControls owner)
this.Owner = owner;
Create();
}
private static string GetSceneId(Scene scene)
{
if (!scene.IsValid())
return "invalid";

if (!string.IsNullOrEmpty(scene.path))
return scene.path;

return scene.name;
}
public void UpdateGameObjectInfo(bool firstUpdate, bool force)
{
if (firstUpdate)
Expand Down Expand Up @@ -92,9 +102,9 @@ public void UpdateGameObjectInfo(bool firstUpdate, bool force)
IsStaticToggle.Set(Target.isStatic, false);
}

if (force || Target.scene.handle != lastSceneHandle)
if (force || GetSceneId(Target.scene) != lastSceneId) //scene.handle no longer exists in unity 6, had to replace it with something else.
{
lastSceneHandle = Target.scene.handle;
lastSceneId = GetSceneId(Target.scene);
SceneButton.ButtonText.text = Target.scene.IsValid() ? Target.scene.name : "None (Asset/Resource)";
}

Expand Down