예제 #1
0
        public GameObject InstantiateObjectHierarchyFromPrefab(Prefab prefab, Transform transformData)
        {
            GameObject instantiatedObject = ObjectInstantiation.InstantiateObjectHierarchyFromPrefab(prefab, transformData.position, transformData.rotation, transformData.lossyScale);

            _gameObjectSphereTree.RegisterGameObjectHierarchy(instantiatedObject);
            return(instantiatedObject);
        }
예제 #2
0
        public GameObject InstantiateObjectHierarchyFromPrefab(Prefab prefab, Vector3 worldPosition, Quaternion worldRotation, Vector3 worldScale)
        {
            GameObject instantiatedObject = ObjectInstantiation.InstantiateObjectHierarchyFromPrefab(prefab, worldPosition, worldRotation, worldScale);

            _gameObjectSphereTree.RegisterGameObjectHierarchy(instantiatedObject);
            return(instantiatedObject);
        }
예제 #3
0
        public GameObject InstantiateObjectHierarchyFromPlacementData(ObjectPlacementData objectPlacementData)
        {
            GameObject instantiatedObject = ObjectInstantiation.InstantiateObjectHierarchyFromPlacementData(objectPlacementData);

            _gameObjectSphereTree.RegisterGameObjectHierarchy(instantiatedObject);
            return(instantiatedObject);
        }
예제 #4
0
        public static List <GameObject> Duplicate(IEnumerable <GameObject> sourceObjects)
        {
            List <GameObject> sourceParents = Octave3DWorldBuilder.ActiveInstance.GetRoots(sourceObjects);

            var clonedObjects = new List <GameObject>();

            foreach (GameObject parent in sourceParents)
            {
                GameObject prefab          = parent.GetSourcePrefab();
                Transform  parentTransform = parent.transform;

                if (prefab == null)
                {
                    GameObject clonedParent = parent.CloneAsWorkingObject(parentTransform.parent);
                    //clonedParent.transform.parent = parent.transform.parent;
                    clonedObjects.AddRange(clonedParent.GetAllChildrenIncludingSelf());
                    Octave3DScene.Get().RegisterObjectHierarchy(clonedParent);
                }
                else
                {
                    GameObject clonedParent = ObjectInstantiation.InstantiateObjectHierarchyFromPrefab(prefab, parentTransform.position, parentTransform.rotation, parentTransform.lossyScale);
                    clonedObjects.AddRange(clonedParent.GetAllChildrenIncludingSelf());
                    Octave3DScene.Get().RegisterObjectHierarchy(clonedParent);
                }
            }

            SceneViewCamera.Instance.SetObjectVisibilityDirty();
            return(clonedObjects);
        }
예제 #5
0
        private static void InstantiateFromPrefab(Prefab prefab)
        {
            _instance = ObjectInstantiation.InstantiateObjectPlacementGuide(prefab, prefab.Name + "(" + _nameSuffix + ")");
            _instance._sourcePrefab      = prefab;
            _instance.transform.rotation = prefab.ActivationSettings.WorldRotation;
            _instance.gameObject.SetWorldScale(prefab.ActivationSettings.WorldScale);

            ObjectPlacementGuideWasInstantiatedMessage.SendToInterestedListeners();
        }
예제 #6
0
        public List <GameObject> InstantiateObjectHirarchiesFromPlacementDataCollection(List <ObjectPlacementData> objectPlacementDataCollection)
        {
            if (objectPlacementDataCollection.Count == 0)
            {
                return(new List <GameObject>());
            }

            var instantiatedHierarchyRoots = ObjectInstantiation.InstantiateObjectHirarchiesFromPlacementDataCollection(objectPlacementDataCollection);

            _gameObjectSphereTree.RegisterGameObjectHierarchies(instantiatedHierarchyRoots);
            return(instantiatedHierarchyRoots);
        }
예제 #7
0
        public static void DuplicateSelection()
        {
            if (ObjectSelection.Get().NumberOfSelectedObjects == 0)
            {
                return;
            }

            ObjectSelection   objectSelection    = ObjectSelection.Get();
            List <GameObject> allSelectedObjects = objectSelection.GetAllSelectedGameObjects();
            List <GameObject> selectedParents    = GameObjectExtensions.GetParents(allSelectedObjects);

            var clonedObjects = new List <GameObject>();
            var clonedParents = new List <GameObject>();

            foreach (GameObject parent in selectedParents)
            {
                GameObject prefab          = parent.GetSourcePrefab();
                Transform  parentTransform = parent.transform;

                if (prefab == null)
                {
                    GameObject clonedParent = parent.CloneAsWorkingObject(parentTransform.parent);
                    //clonedParent.transform.parent = parent.transform.parent;
                    clonedObjects.AddRange(clonedParent.GetAllChildrenIncludingSelf());
                    Octave3DScene.Get().RegisterObjectHierarchy(clonedParent);
                    clonedParents.Add(clonedParent);
                }
                else
                {
                    GameObject clonedParent = ObjectInstantiation.InstantiateObjectHierarchyFromPrefab(prefab, parentTransform.position, parentTransform.rotation, parentTransform.lossyScale);
                    clonedObjects.AddRange(clonedParent.GetAllChildrenIncludingSelf());
                    Octave3DScene.Get().RegisterObjectHierarchy(clonedParent);
                    clonedParents.Add(clonedParent);
                }
            }

            if (clonedObjects.Count != 0)
            {
                objectSelection.Clear();
                objectSelection.AddGameObjectCollectionToSelection(clonedObjects);
                objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdated();
            }

            if (clonedParents.Count != 0)
            {
                ObjectHierarchyRootsWerePlacedInSceneMessage.SendToInterestedListeners(clonedParents, ObjectHierarchyRootsWerePlacedInSceneMessage.PlacementType.Selection);
            }

            SceneViewCamera.Instance.SetObjectVisibilityDirty();
        }
        public static void DuplicateSelection()
        {
            if (ObjectSelection.Get().NumberOfSelectedObjects == 0)
            {
                return;
            }

            ObjectSelection   objectSelection    = ObjectSelection.Get();
            List <GameObject> allSelectedObjects = objectSelection.GetAllSelectedGameObjects();
            List <GameObject> selectedParents    = GameObjectExtensions.GetTopParentsFromGameObjectCollection(allSelectedObjects);

            var clonedObjects = new List <GameObject>();

            foreach (GameObject parent in selectedParents)
            {
                GameObject prefab          = parent.GetSourcePrefab();
                Transform  parentTransform = parent.transform;

                if (prefab == null)
                {
                    GameObject clonedParent = parent.CloneAsWorkingObject(parentTransform.parent);
                    //clonedParent.transform.parent = parent.transform.parent;
                    clonedObjects.AddRange(clonedParent.GetAllChildrenIncludingSelf());
                }
                else
                {
                    GameObject clonedParent = ObjectInstantiation.InstantiateObjectHierarchyFromPrefab(prefab, parentTransform.position, parentTransform.rotation, parentTransform.lossyScale);
                    clonedObjects.AddRange(clonedParent.GetAllChildrenIncludingSelf());
                }
            }

            if (clonedObjects.Count != 0)
            {
                objectSelection.Clear();
                objectSelection.AddGameObjectCollectionToSelection(clonedObjects);
                objectSelection.ObjectSelectionTransformGizmoSystem.OnObjectSelectionUpdated();
            }
        }