0.6.6: Fixed issues with both canvas and scene picker

* Scene: Fixed issue, where scene picker wouldn't update correctly, when in play mode and changing active scene
* Canvas: Fixed issue, where it wasn't possible to select canvas in prefab stage
This commit is contained in:
Anders Ejlersen 2021-09-04 22:54:11 +02:00
parent b07117c9bf
commit 63f2101917
6 changed files with 50 additions and 8 deletions

View file

@ -0,0 +1,26 @@
using Game.NavigationTool.Editor.Tools;
using UnityEditor;
using UnityEngine.SceneManagement;
namespace Game.NavigationTool.Editor.Toolbar
{
[InitializeOnLoad]
internal static class ToolScenePickerEditorStateChanged
{
static ToolScenePickerEditorStateChanged()
{
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
SceneManager.activeSceneChanged += OnActiveSceneChanged;
}
private static void OnPlayModeStateChanged(PlayModeStateChange state)
{
ToolScenePicker.SetAsDirty();
}
private static void OnActiveSceneChanged(Scene current, Scene next)
{
ToolScenePicker.SetAsDirty();
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0590255ee6fc4b03ac5f1905d7249291
timeCreated: 1630787305

View file

@ -1,6 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using JetBrains.Annotations; using JetBrains.Annotations;
using UnityEditor; using UnityEditor;
using UnityEditor.Experimental.SceneManagement;
using UnityEditorInternal; using UnityEditorInternal;
using UnityEngine; using UnityEngine;
using UTools = UnityEditor.Tools; using UTools = UnityEditor.Tools;
@ -22,7 +23,9 @@ namespace Game.NavigationTool.Editor.Tools
if (!IS_DIRTY) if (!IS_DIRTY)
return; return;
Canvas[] canvases = Object.FindObjectsOfType<Canvas>(); PrefabStage prefabStage = PrefabStageUtility.GetCurrentPrefabStage();
Canvas[] canvases = prefabStage != null ? prefabStage.prefabContentsRoot.GetComponentsInParent<Canvas>() : Object.FindObjectsOfType<Canvas>();
var list = new List<Canvas>(canvases.Length); var list = new List<Canvas>(canvases.Length);
var listNames = new List<string>(canvases.Length); var listNames = new List<string>(canvases.Length);
var listIds = new List<int>(canvases.Length); var listIds = new List<int>(canvases.Length);
@ -65,10 +68,10 @@ namespace Game.NavigationTool.Editor.Tools
{ {
return 100.0f; return 100.0f;
} }
private static void Focus(int instanceId) private static void Focus(int instanceId)
{ {
var obj = EditorUtility.InstanceIDToObject(instanceId); Object obj = EditorUtility.InstanceIDToObject(instanceId);
var canvas = obj as Canvas; var canvas = obj as Canvas;
if (canvas == null) if (canvas == null)

View file

@ -1,5 +1,6 @@
using Game.NavigationTool.Editor.Tools; using Game.NavigationTool.Editor.Tools;
using UnityEditor; using UnityEditor;
using UnityEditor.Experimental.SceneManagement;
using UnityEditor.SceneManagement; using UnityEditor.SceneManagement;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
@ -10,13 +11,12 @@ namespace Game.NavigationTool.Editor.Toolbar
{ {
static ToolUICanvasPickerPostProcess() static ToolUICanvasPickerPostProcess()
{ {
EditorSceneManager.sceneSaved -= OnSceneSaved;
EditorSceneManager.sceneOpened -= OnSceneOpened;
EditorSceneManager.sceneClosed -= OnSceneClosed;
EditorSceneManager.sceneSaved += OnSceneSaved; EditorSceneManager.sceneSaved += OnSceneSaved;
EditorSceneManager.sceneOpened += OnSceneOpened; EditorSceneManager.sceneOpened += OnSceneOpened;
EditorSceneManager.sceneClosed += OnSceneClosed; EditorSceneManager.sceneClosed += OnSceneClosed;
PrefabStage.prefabStageOpened += OnPrefabStageOpened;
PrefabStage.prefabStageClosing += OnPrefabStageClosing;
} }
private static void OnSceneSaved(Scene scene) private static void OnSceneSaved(Scene scene)
@ -33,5 +33,15 @@ namespace Game.NavigationTool.Editor.Toolbar
{ {
ToolUICanvasPicker.SetAsDirty(); ToolUICanvasPicker.SetAsDirty();
} }
private static void OnPrefabStageOpened(PrefabStage stage)
{
ToolUICanvasPicker.SetAsDirty();
}
private static void OnPrefabStageClosing(PrefabStage stage)
{
ToolUICanvasPicker.SetAsDirty();
}
} }
} }

View file

@ -1,6 +1,6 @@
{ {
"name": "com.module.navigationtool", "name": "com.module.navigationtool",
"version": "0.6.5", "version": "0.6.6",
"displayName": "Module.NavigationTool", "displayName": "Module.NavigationTool",
"description": "Support for navigation tools, like favorites, history and toolbars", "description": "Support for navigation tools, like favorites, history and toolbars",
"unity": "2019.2", "unity": "2019.2",