static SceneHierarchyHooks.SubSceneInfo[] ProvideSubScenes()
        {
            var scenes       = new SceneHierarchyHooks.SubSceneInfo[SubScene.AllSubScenes.Count()];
            var loadedScenes = new HashSet <Scene>();

            int index = 0;

            foreach (var subScene in SubScene.AllSubScenes)
            {
                var loadedScene    = default(Scene);
                var candidateScene = subScene.LoadedScene;
                if (candidateScene.IsValid() && candidateScene.isSubScene)
                {
                    if (loadedScenes.Add(candidateScene))
                    {
                        loadedScene = candidateScene;
                    }
                }

                scenes[index].transform  = subScene.transform;
                scenes[index].scene      = loadedScene;
                scenes[index].sceneAsset = subScene.SceneAsset;
                scenes[index].color      = subScene.HierarchyColor;
                scenes[index].sceneName  = GetSceneName(subScene.SceneAsset, loadedScene);
                index++;
            }

            return(scenes);
        }
Example #2
0
        static void CreateEmptyChild(MenuCommand menuCommand)
        {
            var parent = menuCommand.context as GameObject;

            if (parent == null)
            {
                var activeGO = Selection.activeGameObject;
                if (activeGO != null && !EditorUtility.IsPersistent(activeGO))
                {
                    parent = activeGO;
                }
            }

            // If selected GameObject is a Sub Scene header, place GameObject in active scene
            // similar to what happens when other scene headers are selected.
            SceneHierarchyHooks.SubSceneInfo info = SubSceneGUI.GetSubSceneInfo(parent);
            if (info.isValid)
            {
                parent = null;
            }

            var go = ObjectFactory.CreateGameObject("GameObject");

            Place(go, parent);
        }
Example #3
0
    internal static int CalculateHierarchyDepthOfSubScene(SceneHierarchyHooks.SubSceneInfo subSceneInfo)
    {
        if (!subSceneInfo.isValid)
        {
            return(-1);
        }

        int hierarchyDepth = 0;
        int i = 0;

        while (i++ < kMaxSubSceneIterations)
        {
            hierarchyDepth += FindTransformDepth(subSceneInfo.transform) + 1;  // the +1 is for the SubScene header
            if (!m_SceneToSubSceneMap.TryGetValue(subSceneInfo.transform.gameObject.scene, out subSceneInfo))
            {
                break;
            }
        }

        if (i >= kMaxSubSceneIterations)
        {
            Debug.LogError("Recursive SubScene setup detected. Report a bug.");
        }

        return(hierarchyDepth);
    }
Example #4
0
    static float CalcIndentOfVerticalLine(SceneHierarchyHooks.SubSceneInfo subSceneInfo, float baseIndent, float indentWidth)
    {
        int hierarchyDepth = CalculateHierarchyDepthOfSubScene(subSceneInfo);

        if (hierarchyDepth > 0)
        {
            return(baseIndent + hierarchyDepth * indentWidth + s_HalfFoldoutWidth);
        }
        return(-1f);
    }
Example #5
0
        static string ProvideSubSceneName(SceneHierarchyHooks.SubSceneInfo subSceneInfo)
        {
            // Use override scene name if set
            if (!string.IsNullOrEmpty(subSceneInfo.sceneName))
            {
                return(subSceneInfo.sceneName);
            }

            return(GetSceneName(subSceneInfo.sceneAsset, subSceneInfo.scene));
        }
Example #6
0
    static float CalcIndentOfVerticalLine(SceneHierarchyHooks.SubSceneInfo subSceneInfo)
    {
        int hierarchyDepth = CalculateHierarchyDepthOfSubScene(subSceneInfo);

        if (hierarchyDepth > 0)
        {
            float indentWidth = 14f;
            float indent      = hierarchyDepth * indentWidth;
            return(indent);
        }
        return(-1f);
    }
Example #7
0
    internal static void CreateClosedSubSceneContextClick(GenericMenu menu, SceneHierarchyHooks.SubSceneInfo subScene)
    {
        var selectAssetContent = EditorGUIUtility.TrTextContent("Select Scene Asset");

        if (subScene.sceneAsset)
        {
            menu.AddItem(selectAssetContent, false, SelectSceneAsset, subScene.sceneAsset);
        }
        else
        {
            menu.AddDisabledItem(selectAssetContent);
        }
    }
Example #8
0
    internal static int CalculateHierarchyDepthOfSubScene(SceneHierarchyHooks.SubSceneInfo subSceneInfo)
    {
        if (!subSceneInfo.isValid)
        {
            return(-1);
        }

        int hierarchyDepth = 0; // Root scene offset

        while (true)
        {
            hierarchyDepth += FindTransformDepth(subSceneInfo.transform) + 1;  // the +1 is for the SubScene header
            if (!m_SceneToSubSceneMap.TryGetValue(subSceneInfo.transform.gameObject.scene, out subSceneInfo))
            {
                break;
            }
        }

        return(hierarchyDepth);
    }
        static SceneHierarchyHooks.SubSceneInfo[] ProvideSubScenes()
        {
            var scenes      = new SceneHierarchyHooks.SubSceneInfo[SubScene.AllSubScenes.Count()];
            var sceneAssets = new HashSet <SceneAsset>();

            int index = 0;

            foreach (var subScene in SubScene.AllSubScenes)
            {
                var duplicateSceneAsset = subScene.SceneAsset != null && !sceneAssets.Add(subScene.SceneAsset);
                var isNestedSubScene    = subScene.gameObject.scene.isSubScene;
                if (isNestedSubScene)
                {
                    scenes[index].sceneName = "WARNING: Nesting SubScenes is not supported yet";
                }
                else if (duplicateSceneAsset)
                {
                    scenes[index].sceneName = $"WARNING: Duplicate SubScene: '{subScene.SceneAsset.name}'";
                }

                var loadedScene = default(Scene);
                if (!duplicateSceneAsset && !isNestedSubScene)
                {
                    var candidateScene = subScene.EditingScene;
                    if (candidateScene.IsValid() && candidateScene.isSubScene)
                    {
                        loadedScene = candidateScene;
                    }
                }

                scenes[index].transform  = subScene.transform;
                scenes[index].scene      = loadedScene;
                scenes[index].sceneAsset = subScene.SceneAsset;
                scenes[index].color      = subScene.HierarchyColor;
                index++;
            }

            return(scenes);
        }
Example #10
0
        static SceneHierarchyHooks.SubSceneInfo[] ProvideSubScenes()
        {
            var scenes      = new SceneHierarchyHooks.SubSceneInfo[SubScene.AllSubScenes.Count()];
            var sceneAssets = new HashSet <SceneAsset>();

            int index = 0;

            foreach (var subScene in SubScene.AllSubScenes)
            {
                var isSubSceneInMainStage = subScene.IsInMainStage();
                var duplicateSceneAsset   = subScene.SceneAsset != null && isSubSceneInMainStage && !sceneAssets.Add(subScene.SceneAsset);
                var transform             = subScene.transform;
                if (duplicateSceneAsset)
                {
                    scenes[index].sceneName = $"{subScene.SceneAsset.name}  (Duplicate Scene)";
                }

                var loadedScene = default(Scene);
                if (isSubSceneInMainStage && !duplicateSceneAsset)
                {
                    var candidateScene = subScene.EditingScene;
                    if (candidateScene.IsValid() && candidateScene.isSubScene)
                    {
                        loadedScene = candidateScene;
                    }
                }

                scenes[index].transform  = subScene.transform;
                scenes[index].scene      = loadedScene;
                scenes[index].sceneAsset = subScene.SceneAsset;
                scenes[index].color      = subScene.HierarchyColor;
                index++;
            }

            return(scenes);
        }