Exemplo n.º 1
0
        static void CheckInputArguments(NewSubSceneArgs args, out Scene parentScene, out GameObject targetGameObject, out GameObject[] topLevelGameObjects)
        {
            targetGameObject = args.target;
            parentScene      = targetGameObject != null ? targetGameObject.scene : args.parentScene;
            if (!parentScene.isLoaded && args.target == null)
            {
                throw new InvalidOperationException("Creating a Sub Scene needs a target GameObject or a valid parent Scene");
            }

            switch (args.newSubSceneMode)
            {
            case NewSubSceneMode.EmptyScene:
                topLevelGameObjects = new GameObject[0];
                break;

            case NewSubSceneMode.MoveSelectionToScene:
                topLevelGameObjects = GetValidSelectedGameObjectsForSubSceneCreation(targetGameObject);
                if (topLevelGameObjects == null)
                {
                    throw new InvalidOperationException("Cannot create Sub Scene from Selection");
                }
                break;

            default:
                throw new InvalidOperationException("Unhandled enum");
            }
        }
Exemplo n.º 2
0
        internal static SubScene CreateNewSubScene(string name, NewSubSceneArgs args, InteractionMode interactionMode)
        {
            GameObject targetGameObject;
            Scene      parentScene;

            GameObject[] topLevelGameObjects;
            CheckInputArguments(args, out parentScene, out targetGameObject, out topLevelGameObjects);

            return(CreateSubSceneAndMoveObjectsInside(parentScene, targetGameObject?.transform, topLevelGameObjects, name, interactionMode));
        }
Exemplo n.º 3
0
        internal static SubScene CreateSubSceneAndAddSelection(GameObject gameObject, InteractionMode interactionMode = InteractionMode.AutomatedAction)
        {
            var args = new NewSubSceneArgs(gameObject, default(Scene), NewSubSceneMode.MoveSelectionToScene);

            return(CreateNewSubScene(gameObject.name, args, interactionMode));
        }