Beispiel #1
0
        /// <summary>
        /// Sets keyboard focus to the Hierarchy or Scene windows if open.
        /// </summary>
        private static void FocusOnHierarchyOrScene()
        {
            SceneWindow sceneWindow = EditorWindow.GetWindow <SceneWindow>();

            if (sceneWindow != null)
            {
                sceneWindow.HasFocus = true;
                return;
            }

            HierarchyWindow hierarchyWindow = EditorWindow.GetWindow <HierarchyWindow>();

            if (hierarchyWindow != null)
            {
                hierarchyWindow.HasFocus = true;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Manually triggers a global shortcut.
        /// </summary>
        /// <param name="btn">Button for the shortcut. If this doesn't correspond to any shortcut, it is ignored.</param>
        internal static void TriggerGlobalShortcut(VirtualButton btn)
        {
            IGlobalShortcuts window = null;

            if (btn != PasteKey)
            {
                // The system ensures elsewhere that only either a resource or a scene object is selected, but not both
                if (Selection.ResourcePaths.Length > 0)
                {
                    window = EditorWindow.GetWindow <LibraryWindow>();
                }
                else if (Selection.SceneObjects.Length > 0)
                {
                    window = EditorWindow.GetWindow <HierarchyWindow>();
                    if (window == null)
                    {
                        window = EditorWindow.GetWindow <SceneWindow>();
                    }
                }

                if (window != null)
                {
                    if (btn == CopyKey)
                    {
                        window.OnCopyPressed();
                    }
                    else if (btn == CutKey)
                    {
                        window.OnCutPressed();
                    }
                    else if (btn == PasteKey)
                    {
                        window.OnPastePressed();
                    }
                    else if (btn == DuplicateKey)
                    {
                        window.OnDuplicatePressed();
                    }
                    else if (btn == RenameKey)
                    {
                        window.OnRenamePressed();
                    }
                    else if (btn == DeleteKey)
                    {
                        window.OnDeletePressed();
                    }
                }
            }
            else
            {
                HierarchyWindow hierarchy = EditorWindow.GetWindow <HierarchyWindow>();
                if (hierarchy != null && hierarchy.HasFocus)
                {
                    window = hierarchy;
                }
                else
                {
                    LibraryWindow library = EditorWindow.GetWindow <LibraryWindow>();
                    if (library != null && library.HasFocus)
                    {
                        window = library;
                    }
                }

                if (window != null)
                {
                    window.OnPastePressed();
                }
            }
        }