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:
parent
b07117c9bf
commit
63f2101917
26
Editor/Toolbar/Tools/ToolScenePickerEditorStateChanged.cs
Normal file
26
Editor/Toolbar/Tools/ToolScenePickerEditorStateChanged.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0590255ee6fc4b03ac5f1905d7249291
|
||||
timeCreated: 1630787305
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Experimental.SceneManagement;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UTools = UnityEditor.Tools;
|
||||
|
|
@ -22,7 +23,9 @@ namespace Game.NavigationTool.Editor.Tools
|
|||
if (!IS_DIRTY)
|
||||
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 listNames = new List<string>(canvases.Length);
|
||||
var listIds = new List<int>(canvases.Length);
|
||||
|
|
@ -68,7 +71,7 @@ namespace Game.NavigationTool.Editor.Tools
|
|||
|
||||
private static void Focus(int instanceId)
|
||||
{
|
||||
var obj = EditorUtility.InstanceIDToObject(instanceId);
|
||||
Object obj = EditorUtility.InstanceIDToObject(instanceId);
|
||||
var canvas = obj as Canvas;
|
||||
|
||||
if (canvas == null)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using Game.NavigationTool.Editor.Tools;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Experimental.SceneManagement;
|
||||
using UnityEditor.SceneManagement;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
|
@ -10,13 +11,12 @@ namespace Game.NavigationTool.Editor.Toolbar
|
|||
{
|
||||
static ToolUICanvasPickerPostProcess()
|
||||
{
|
||||
EditorSceneManager.sceneSaved -= OnSceneSaved;
|
||||
EditorSceneManager.sceneOpened -= OnSceneOpened;
|
||||
EditorSceneManager.sceneClosed -= OnSceneClosed;
|
||||
|
||||
EditorSceneManager.sceneSaved += OnSceneSaved;
|
||||
EditorSceneManager.sceneOpened += OnSceneOpened;
|
||||
EditorSceneManager.sceneClosed += OnSceneClosed;
|
||||
|
||||
PrefabStage.prefabStageOpened += OnPrefabStageOpened;
|
||||
PrefabStage.prefabStageClosing += OnPrefabStageClosing;
|
||||
}
|
||||
|
||||
private static void OnSceneSaved(Scene scene)
|
||||
|
|
@ -33,5 +33,15 @@ namespace Game.NavigationTool.Editor.Toolbar
|
|||
{
|
||||
ToolUICanvasPicker.SetAsDirty();
|
||||
}
|
||||
|
||||
private static void OnPrefabStageOpened(PrefabStage stage)
|
||||
{
|
||||
ToolUICanvasPicker.SetAsDirty();
|
||||
}
|
||||
|
||||
private static void OnPrefabStageClosing(PrefabStage stage)
|
||||
{
|
||||
ToolUICanvasPicker.SetAsDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.module.navigationtool",
|
||||
"version": "0.6.5",
|
||||
"version": "0.6.6",
|
||||
"displayName": "Module.NavigationTool",
|
||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||
"unity": "2019.2",
|
||||
|
|
|
|||
Loading…
Reference in a new issue