Пример #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;
            }
        }
Пример #2
0
 public static void Duplicate()
 {
     if (Selection.SceneObjects != null && Selection.SceneObjects.Length > 0)
     {
         HierarchyWindow win = EditorWindow.GetWindow <HierarchyWindow>();
         if (win != null)
         {
             win.DuplicateSelection();
         }
     }
     else if (Selection.ResourcePaths != null && Selection.ResourcePaths.Length > 0)
     {
         LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();
         if (win != null)
         {
             win.DuplicateSelection();
         }
     }
 }
Пример #3
0
        public static void Paste()
        {
            // TODO - This is slightly wrong in case both windows have something in their paste buffer (unify them?)

            {
                HierarchyWindow win = EditorWindow.GetWindow <HierarchyWindow>();
                if (win != null)
                {
                    win.PasteToSelection();
                }
            }

            {
                LibraryWindow win = EditorWindow.GetWindow <LibraryWindow>();
                if (win != null)
                {
                    win.PasteToSelection();
                }
            }
        }
Пример #4
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();
                }
            }
        }