void SetItemIcon(GameObjectTreeViewItem item)
        {
            var go = item.objectPPTR as GameObject;

            if (go == null)
            {
                if (IsPrefabStageHeader(item))
                {
                    string prefabAssetPath = PrefabStageUtility.GetCurrentPrefabStage().prefabAssetPath;
                    item.icon = (Texture2D)AssetDatabase.GetCachedIcon(prefabAssetPath);
                }
                else
                {
                    item.icon = GameObjectStyles.sceneAssetIcon;
                }
            }
            else
            {
                if (SubSceneGUI.IsSubSceneHeader(go))
                {
                    item.icon = GameObjectStyles.sceneAssetIcon;
                }
                else
                {
                    item.icon = PrefabUtility.GetIconForGameObject(go);
                }
            }
        }
 int GetDropTargetInstanceID(GameObjectTreeViewItem hierarchyTargetItem, DropPosition dropPosition)
 {
     if (SubSceneGUI.IsUsingSubScenes())
     {
         var gameObjectDropTarget = hierarchyTargetItem.objectPPTR as GameObject;
         if (gameObjectDropTarget != null)
         {
             if (dropPosition == DropPosition.Above)
             {
                 return(hierarchyTargetItem.id);
             }
             if (SubSceneGUI.IsSubSceneHeader(gameObjectDropTarget))
             {
                 Scene subScene = SubSceneGUI.GetSubScene(gameObjectDropTarget);
                 if (subScene.IsValid())
                 {
                     return(subScene.handle);
                 }
                 else
                 {
                     return(0);
                 }
             }
         }
     }
     return(hierarchyTargetItem.id);
 }
Exemplo n.º 3
0
        private static bool CanSetParent(Transform transform, Transform target)
        {
            bool canSetParent = transform != target;

            if (target != null)
            {
                canSetParent = canSetParent && !transform.IsChildOf(target) && !target.IsChildOf(transform);
            }
            if (SubSceneGUI.IsSubSceneHeader(transform.gameObject))
            {
                canSetParent = canSetParent && !SubSceneGUI.IsChildOrSameAsOtherTransform(transform, target) && !SubSceneGUI.IsChildOrSameAsOtherTransform(target, transform);
            }

            return(canSetParent);
        }
Exemplo n.º 4
0
        override public bool IsRenamingItemAllowed(TreeViewItem item)
        {
            GameObjectTreeViewItem goItem = item as GameObjectTreeViewItem;

            if (goItem.isSceneHeader)
            {
                return(false);
            }

            if (SubSceneGUI.IsUsingSubScenes() && SubSceneGUI.IsSubSceneHeader((GameObject)goItem.objectPPTR))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        internal static bool CanPasteAsChild()
        {
            bool canPaste = (Unsupported.CanPasteGameObjectsFromPasteboard() || CutBoard.hasCutboardData) &&
                            ((SceneHierarchyWindow.lastInteractedHierarchyWindow != null && SceneHierarchyWindow.lastInteractedHierarchyWindow.sceneHierarchy != null) ||
                             SceneView.lastActiveSceneView != null) &&
                            Selection.transforms.Length == 1;

            var activeGO = Selection.activeGameObject;

            if (activeGO != null && SubSceneGUI.IsSubSceneHeader(activeGO))
            {
                return(canPaste && SubSceneGUI.GetSubScene(activeGO).IsValid());
            }

            return(canPaste);
        }
        internal static void PasteGOAsChild()
        {
            Transform[] selected = Selection.transforms;

            // paste as a child if a gameObject is selected
            if (selected.Length == 1)
            {
                Scene subScene        = new Scene();
                bool  pasteToSubScene = false;
                bool  isSubScene      = false;

                // If target is subScene make sure we just move objects under subScene
                if (SubSceneGUI.IsSubSceneHeader(selected[0].gameObject))
                {
                    subScene        = SubSceneGUI.GetSubScene(selected[0].gameObject);
                    isSubScene      = subScene.isSubScene;
                    pasteToSubScene = subScene.IsValid();
                }

                // handle paste after cut
                if (CutBoard.hasCutboardData)
                {
                    if (pasteToSubScene)
                    {
                        if (subScene.handle != 0)
                        {
                            CutBoard.PasteToScene(subScene, selected[0]);
                            pastedGameObjects?.Invoke(Selection.gameObjects);
                        }
                    }
                    else if (!isSubScene)
                    {
                        CutBoard.PasteAsChildren(selected[0]);
                        pastedGameObjects?.Invoke(Selection.gameObjects);
                    }
                }
                // paste after copy
                else if (pasteToSubScene || !isSubScene)
                {
                    Unsupported.PasteGameObjectsFromPasteboard(selected[0], pasteToSubScene ? subScene.handle : 0);
                    pastedGameObjects?.Invoke(Selection.gameObjects);
                }
            }
            RepaintHierarchyWindowsAfterPaste();
        }
        void SetItemIcon(GameObjectTreeViewItem item)
        {
            var go = item.objectPPTR as GameObject;

            if (go == null)
            {
                item.icon = GameObjectStyles.sceneIcon;
            }
            else
            {
                if (SubSceneGUI.IsSubSceneHeader(go))
                {
                    item.icon = GameObjectStyles.sceneIcon;
                }
                else
                {
                    item.icon = PrefabUtility.GetIconForGameObject(go);
                }
            }
        }
        override protected void DrawItemBackground(Rect rect, int row, TreeViewItem item, bool selected, bool focused)
        {
            var goItem = (GameObjectTreeViewItem)item;

            if (goItem.isSceneHeader)
            {
                GUI.Label(rect, GUIContent.none, GameObjectStyles.sceneHeaderBg);
            }
            else
            {
                // Don't show indented sub scene header backgrounds when searching (as the texts are not indented here)
                if (SubSceneGUI.IsUsingSubScenes() && !showingSearchResults)
                {
                    var gameObject = (GameObject)goItem.objectPPTR;
                    if (gameObject != null && SubSceneGUI.IsSubSceneHeader(gameObject))
                    {
                        SubSceneGUI.DrawSubSceneHeaderBackground(rect, k_BaseIndent, k_IndentWidth, gameObject);
                    }
                }
            }

            if (m_TreeView.hoveredItem != item)
            {
                return;
            }

            if (isDragging)
            {
                return;
            }

            using (new GUI.BackgroundColorScope(GameObjectStyles.hoveredBackgroundColor))
            {
                GUI.Label(rect, GUIContent.none, GameObjectStyles.hoveredItemBackgroundStyle);
            }
        }