internal static void OnToolGUI(EditorWindow window) { activeToolContext.OnToolGUI(window); if (Tools.s_Hidden || instance.m_ActiveTool == null) { return; } var current = instance.m_ActiveTool; using (new EditorGUI.DisabledScope(!current.IsAvailable())) { current.OnToolGUI(window); } var evt = Event.current; if (evt.type == EventType.KeyDown && evt.keyCode == KeyCode.Escape) { if (!Tools.viewToolActive && !EditorToolUtility.IsManipulationTool(EditorToolUtility.GetEnumWithEditorTool(current, instance.m_ActiveToolContext)) && additionalContextToolTypesCache.All(toolType => toolType != current.GetType())) { RestorePreviousPersistentTool(); evt.Use(); } else { //if is in a Manipulation or additional tool leaves the current context to return to GameObject Context ToolManager.SetActiveContext <GameObjectToolContext>(); } } }
internal static EditorTool GetLastCustomTool() { for (int i = instance.m_ToolHistory.Count - 1; i > -1; i--) { if (EditorToolUtility.GetEnumWithEditorTool(instance.m_ToolHistory[i]) == Tool.Custom) { return(instance.m_ToolHistory[i]); } } return(null); }
internal static void GetToolHistory(List <EditorTool> tools, bool customToolsOnly = false) { tools.Clear(); instance.CleanupToolHistory(); for (int i = instance.m_ToolHistory.Count - 1; i > -1; i--) { if (!customToolsOnly || EditorToolUtility.GetEnumWithEditorTool(instance.m_ToolHistory[i]) == Tool.Custom) { tools.Add(instance.m_ToolHistory[i]); } } }
public UnityObject InstantiateEditor() { var toolType = editorType; m_Editor = ScriptableObject.CreateInstance(toolType, x => { ((IEditor)x).SetTargets(targets); ((IEditor)x).SetTarget(target); }); m_Editor.hideFlags = HideFlags.DontSave; if (m_Editor is EditorToolContext) { m_EditorToolScope = EditorToolScope.ToolContext; } else if (m_Editor is EditorTool tool && EditorToolUtility.GetEnumWithEditorTool(tool, EditorToolManager.activeToolContext) != Tool.Custom) { m_EditorToolScope = EditorToolScope.ManipulationToolOverride; }