Пример #1
0
        private void PlaceObjectFromPlacementGuide(bool checkForIntersection)
        {
            ObjectPlacementGuide placementGuide      = ObjectPlacementGuide.Instance;
            GameObject           placedHierarchyRoot = null;

            OrientedBox       guideHierarchyWorldOrientedBox = ObjectPlacementGuide.SceneObject.GetHierarchyWorldOrientedBox();
            List <GameObject> intersectingObjects            = ObjectQueries.GetIntersectingObjects(guideHierarchyWorldOrientedBox, new List <GameObject> {
                _strokeSurface.SurfaceObject
            }, true);

            if (!checkForIntersection || ObjectPlacementSettings.Get().ObjectIntersectionSettings.AllowIntersectionForDecorPaintSingleModeDrag ||
                intersectingObjects.Count == 0)
            {
                placedHierarchyRoot = Octave3DScene.Get().InstantiateObjectHierarchyFromPrefab(placementGuide.SourcePrefab, placementGuide.gameObject.transform);
                ObjectHierarchyRootsWerePlacedInSceneMessage.SendToInterestedListeners(placedHierarchyRoot, ObjectHierarchyRootsWerePlacedInSceneMessage.PlacementType.ObjectPlacement);

                List <GameObject> allPlacedObjects = placedHierarchyRoot.GetAllChildrenIncludingSelf();
                _objectsPlacedWhileDragging.AddRange(allPlacedObjects);
                DecorPaintObjectPlacement.Get().DecorPaintMask.ObjectCollectionMask.Mask(allPlacedObjects);
            }

            _orientedBoxOfLastPlacedHierarchy = ObjectPlacementGuide.SceneObject.GetHierarchyWorldOrientedBox();
            _pivotPointsOfLastPlacedHierarchy.FromOrientedBoxAndDecorStrokeSurface(_orientedBoxOfLastPlacedHierarchy, _strokeSurface);

            if (DecorPaintObjectPlacementSettings.Get().SingleDecorPaintModeSettings.RandomizePrefabsInActiveCategory)
            {
                PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory;
                if (activePrefabCategory != null)
                {
                    activePrefabCategory.RandomizeActivePrefab();
                }
            }
        }
        private static void EnsureGuideUsesBeginTileConnectionPrefab()
        {
            ObjectPlacementPathTileConnectionSettings     tileConnectionSettings      = ObjectPlacement.Get().PathObjectPlacement.PathSettings.TileConnectionSettings;
            ObjectPlacementPathTileConnectionTypeSettings beginTileConnectionSettings = tileConnectionSettings.GetSettingsForTileConnectionType(ObjectPlacementPathTileConnectionType.Begin);

            if (CanRefreshGuideToUseBeginTileConnectionPrefab(beginTileConnectionSettings))
            {
                PrefabCategory categoryWhichContainsBeginPrefab = PrefabCategoryDatabase.Get().GetPrefabCategoryWhichContainsPrefab(beginTileConnectionSettings.Prefab);
                if (categoryWhichContainsBeginPrefab == null)
                {
                    return;
                }

                PrefabCategoryDatabase.Get().SetActivePrefabCategory(categoryWhichContainsBeginPrefab);
                categoryWhichContainsBeginPrefab.SetActivePrefab(beginTileConnectionSettings.Prefab);

                ObjectPlacement.Get().DestroyPlacementGuide();
                ObjectPlacementGuide.CreateFromActivePrefabIfNotExists();
            }

            // Note: When using tile connections, we will always use the original prefab scale
            if (ObjectPlacementGuide.ExistsInScene)
            {
                ObjectPlacementGuide.Instance.WorldScale = beginTileConnectionSettings.Prefab.InitialWorldScale;
            }
        }
Пример #3
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();
        }
Пример #4
0
        private void Initialize()
        {
            MessageListenerRegistration.PerformRegistrationForObjectPlacementGuide(this);
            _instance  = this;
            _transform = transform;

            EditorApplication.update -= OnEditorUpdate;
            EditorApplication.update += OnEditorUpdate;
        }
Пример #5
0
        private void OnDestroy()
        {
            if (_instance == this)
            {
                MessageListenerDatabase.Instance.UnregisterListener(this);
                _instance = null;

                EditorApplication.update -= OnEditorUpdate;
            }
        }
Пример #6
0
        public List <GameObject> GetImmediateChildrenExcludingPlacementGuide()
        {
            List <GameObject> immediateChildren = gameObject.GetImmediateChildren();

            if (ObjectPlacementGuide.ExistsInScene)
            {
                immediateChildren.RemoveAll(item => ObjectPlacementGuide.Equals(item) || ObjectPlacementGuide.ContainsChild(item.transform));
            }

            return(immediateChildren);
        }
Пример #7
0
        public List <GameObject> GetSceneObjectsExceptPlacementGuide()
        {
            List <GameObject> sceneObjects = GetSceneObjects();

            if (ObjectPlacementGuide.ExistsInScene)
            {
                sceneObjects.RemoveAll(item => ObjectPlacementGuide.Equals(item) || ObjectPlacementGuide.ContainsChild(item.transform));
            }

            return(sceneObjects);
        }
Пример #8
0
        public static ObjectPlacementGuide InstantiateObjectPlacementGuide(Prefab prefab, string name)
        {
            GameObject guideObject = Octave3DWorldBuilder.Instantiate(prefab.UnityPrefab) as GameObject;

            guideObject.name = name;
            ObjectPlacementGuide objectPlacementGuide = guideObject.AddComponent <ObjectPlacementGuide>();

            guideObject.transform.parent = Octave3DWorldBuilder.ActiveInstance.transform;

            guideObject.SetSelectedHierarchyWireframeHidden(ObjectPlacementSettings.Get().HideWireframeWhenPlacingObjects);
            return(objectPlacementGuide);
        }
Пример #9
0
        public static void PerformRegistrationForObjectPlacementGuide(ObjectPlacementGuide objectPlacementGuide)
        {
            if (objectPlacementGuide != null)
            {
                MessageListenerDatabase listenerDatabase = MessageListenerDatabase.Instance;
                listenerDatabase.UnregisterListener(objectPlacementGuide);

                listenerDatabase.RegisterListenerForMessage(MessageType.NewPrefabWasActivated, objectPlacementGuide);
                listenerDatabase.RegisterListenerForMessage(MessageType.NewPrefabCategoryWasActivated, objectPlacementGuide);
                listenerDatabase.RegisterListenerForMessage(MessageType.PrefabWasRemovedFromCategory, objectPlacementGuide);
                listenerDatabase.RegisterListenerForMessage(MessageType.PrefabCategoryWasRemovedFromDatabase, objectPlacementGuide);
                listenerDatabase.RegisterListenerForMessage(MessageType.UndoRedoWasPerformed, objectPlacementGuide);
            }
        }
        private void PlaceObject()
        {
            ObjectPlacementGuide placementGuide      = ObjectPlacementGuide.Instance;
            GameObject           placedHierarchyRoot = Octave3DScene.Get().InstantiateObjectHierarchyFromPrefab(placementGuide.SourcePrefab, placementGuide.WorldPosition, placementGuide.WorldRotation, placementGuide.WorldScale);

            ObjectHierarchyRootsWerePlacedInSceneMessage.SendToInterestedListeners(placedHierarchyRoot, ObjectHierarchyRootsWerePlacedInSceneMessage.PlacementType.ObjectPlacement);

            if (PointAndClickObjectPlacementSettings.Get().RandomizePrefabsInActiveCategory)
            {
                PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory;
                if (activePrefabCategory != null)
                {
                    activePrefabCategory.RandomizeActivePrefab();
                }
            }
        }
        private static void EnsureGuideUsesActivePrefab()
        {
            PrefabCategory activePrefabCategory = PrefabCategoryDatabase.Get().ActivePrefabCategory;

            if (activePrefabCategory != null)
            {
                Prefab activePrefab = activePrefabCategory.ActivePrefab;
                if (activePrefab != null)
                {
                    if (!ObjectPlacementGuide.ExistsInScene)
                    {
                        ObjectPlacementGuide.CreateFromActivePrefabIfNotExists();
                    }
                    else if (ObjectPlacementGuide.Instance.SourcePrefab != activePrefab)
                    {
                        ObjectPlacement.Get().DestroyPlacementGuide();
                        ObjectPlacementGuide.CreateFromActivePrefabIfNotExists();
                    }
                }
            }
        }
Пример #12
0
 public static bool IsGameObjectPartOfPlacementGuideHierarchy(GameObject gameObject)
 {
     return(ObjectPlacementGuide.ExistsInScene && (ObjectPlacementGuide.Equals(gameObject) || ObjectPlacementGuide.ContainsChild(gameObject.transform)));
 }