/*
         * void DisableVisualObjects()
         * {
         *      //Debug.Log("DisableVisualObjects");
         *
         *      if (visualDragGameObject != null)
         *      {
         *              for (int i = visualDragGameObject.Count - 1; i >= 0; i--)
         *              {
         *                      var obj = visualDragGameObject[i];
         *                      if (!obj)
         *                              continue;
         *                      if (obj.activeSelf)
         *                      {
         *                              obj.SetActive(false);
         *                      }
         *              }
         *
         *              InternalCSGModelManager.CheckTransformChanged();
         *              InternalCSGModelManager.OnHierarchyModified();
         *              InternalCSGModelManager.UpdateRemoteMeshes();
         *      }
         * }
         */
        void EnableVisualObjects()
        {
            //Debug.Log("EnableVisualObjects");
            if (visualDragGameObject == null ||
                visualDragGameObject.Count != dragGameObjects.Count)
            {
                CreateVisualObjects();
            }             /*else
                           * {
                           *    for (int i = 0; i < dragGameObjects.Count; i++)
                           *    {
                           *            if (!visualDragGameObject[i])
                           *                    continue;
                           *            visualDragGameObject[i].SetActive(dragGameObjects[i].activeSelf);
                           *    }
                           * }*/

            var realParent = (!hoverParent || PrefabUtility.GetPrefabParent(hoverParent.gameObject) != null) ? null : hoverParent;

            int counter = 0;

            foreach (var obj in visualDragGameObject)
            {
                if (!obj)
                {
                    continue;
                }
                obj.transform.rotation = hoverRotation;
                obj.transform.position = hoverPosition;
                if (realParent)
                {
                    obj.transform.SetParent(realParent, true);
                }
                else
                {
                    obj.transform.parent = null;
                }
                obj.transform.SetSiblingIndex(hoverSiblingIndex + counter);
                counter++;
            }

            InternalCSGModelManager.CheckTransformChanged();
            InternalCSGModelManager.OnHierarchyModified();
            InternalCSGModelManager.UpdateMeshes(forceUpdate: true);
            MeshInstanceManager.UpdateHelperSurfaceVisibility();

            if (ignoreBrushes == null && visualDragGameObject != null)
            {
                var foundIgnoreBrushes = new List <CSGBrush>();
                foreach (var obj in visualDragGameObject)
                {
                    foundIgnoreBrushes.AddRange(obj.GetComponentsInChildren <CSGBrush>());
                }

                ignoreBrushes = foundIgnoreBrushes.ToArray();
            }
        }
예제 #2
0
        void EnableVisualObjects()
        {
            //Debug.Log("EnableVisualObjects");
            if (visualDragGameObject == null ||
                visualDragGameObject.Count != dragGameObjects.Count)
            {
                CreateVisualObjects();
            }
            else
            {
                for (int i = 0; i < dragGameObjects.Count; i++)
                {
                    if (visualDragGameObject[i] == null || !visualDragGameObject[i])
                    {
                        continue;
                    }
                    visualDragGameObject[i].SetActive(dragGameObjects[i].activeSelf);
                }
            }

            int counter = 0;

            foreach (var obj in visualDragGameObject)
            {
                if (obj == null || !obj)
                {
                    continue;
                }
                obj.transform.rotation = hoverRotation;
                obj.transform.position = hoverPosition;
                if (hoverParent != null && !SelectionUtility.IsPrefab(hoverParent.gameObject))
                {
                    obj.transform.SetParent(hoverParent, true);
                }
                obj.transform.SetSiblingIndex(hoverSiblingIndex + counter);
                counter++;
            }

            InternalCSGModelManager.CheckTransformChanged();
            InternalCSGModelManager.OnHierarchyModified();
            InternalCSGModelManager.UpdateMeshes(forceUpdate: true);
            MeshInstanceManager.UpdateHelperSurfaceVisibility();
        }
예제 #3
0
        public static void CheckForChanges(bool forceHierarchyUpdate = false)
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }

            if (!forceHierarchyUpdate && skipCheckForChanges)
            {
                return;
            }

            lock (_lockObj)
            {
                if (!_isInitialized)
                {
                    RegisterAllComponents();
                    forceHierarchyUpdate = true;
                    _isInitialized       = true;

                    InternalCSGModelManager.OnHierarchyModified();
                    UpdateRemoteMeshes();
                }

                forceHierarchyUpdate = InternalCSGModelManager.UpdateModelSettings() || forceHierarchyUpdate;

                // unfortunately this is the only reliable way I could find
                // to determine when a transform is modified, either in
                // the inspector or the scene.
                InternalCSGModelManager.CheckTransformChanged(forceHierarchyUpdate);

                if (_isHierarchyModified || forceHierarchyUpdate)
                {
                    InternalCSGModelManager.OnHierarchyModified();
                    InternalCSGModelManager.OnHierarchyModified();
                    _isHierarchyModified = false;
                }

                InternalCSGModelManager.UpdateMeshes();
                MeshInstanceManager.UpdateHelperSurfaceVisibility();
            }
        }
예제 #4
0
        public static void HideObjectsRemoteOnly(List <GameObject> gameObjects)
        {
            if (gameObjects == null ||
                gameObjects.Count == 0)
            {
                return;
            }

            for (var i = gameObjects.Count - 1; i >= 0; i--)
            {
                if (gameObjects[i])
                {
                    gameObjects[i].SetActive(false);
                }
            }

            InternalCSGModelManager.CheckTransformChanged();
            InternalCSGModelManager.OnHierarchyModified();
            InternalCSGModelManager.UpdateRemoteMeshes();
        }
예제 #5
0
 public void DragExited(SceneView sceneView)
 {
     try
     {
         InternalCSGModelManager.skipCheckForChanges = true;
         try { CleanUp(); } catch { }
         InternalCSGModelManager.CheckTransformChanged();
         InternalCSGModelManager.OnHierarchyModified();
         InternalCSGModelManager.UpdateMeshes(forceUpdate: true);
         MeshInstanceManager.UpdateHelperSurfaceVisibility();
         HandleUtility.Repaint();
     }
     finally
     {
         InternalCSGModelManager.skipCheckForChanges = false;
         RealtimeCSG.CSGGrid.ForcedGridCenter        = prevForcedGridCenter;
         RealtimeCSG.CSGGrid.ForcedGridRotation      = prevForcedGridRotation;
         RealtimeCSG.CSGGrid.ForceGrid = false;
     }
 }
예제 #6
0
 public override void DragExited(bool inSceneView)
 {
     try
     {
         InternalCSGModelManager.skipRefresh = true;
         CleanUp();
         InternalCSGModelManager.CheckTransformChanged();
         InternalCSGModelManager.OnHierarchyModified();
         InternalCSGModelManager.UpdateMeshes(forceUpdate: true);
         MeshInstanceManager.UpdateHelperSurfaceVisibility();
         HandleUtility.Repaint();
     }
     finally
     {
         InternalCSGModelManager.skipRefresh = false;
         Grid.ForcedGridCenter   = prevForcedGridCenter;
         Grid.ForcedGridRotation = prevForcedGridRotation;
         Grid.ForceGrid          = false;
     }
 }
예제 #7
0
        public static void ShowObjectsAndUpdate(List <GameObject> gameObjects)
        {
            if (gameObjects == null ||
                gameObjects.Count == 0)
            {
                return;
            }

            for (var i = gameObjects.Count - 1; i >= 0; i--)
            {
                if (gameObjects[i])
                {
                    gameObjects[i].SetActive(true);
                }
            }

            InternalCSGModelManager.CheckTransformChanged();
            InternalCSGModelManager.OnHierarchyModified();
            InternalCSGModelManager.UpdateMeshes(forceUpdate: true);
            MeshInstanceManager.UpdateHelperSurfaceVisibility();
        }
예제 #8
0
        void DisableVisualObjects()
        {
            //Debug.Log("DisableVisualObjects");

            if (visualDragGameObject != null)
            {
                for (int i = visualDragGameObject.Count - 1; i >= 0; i--)
                {
                    var obj = visualDragGameObject[i];
                    if (obj == null || !obj)
                    {
                        continue;
                    }
                    if (obj.activeSelf)
                    {
                        obj.SetActive(false);
                    }
                }

                InternalCSGModelManager.CheckTransformChanged();
                InternalCSGModelManager.OnHierarchyModified();
                InternalCSGModelManager.UpdateRemoteMeshes();
            }
        }
예제 #9
0
        public void DragPerform(SceneView sceneView)
        {
            try
            {
                InternalCSGModelManager.skipCheckForChanges = true;
                if (visualDragGameObject == null)
                {
                    CreateVisualObjects(sceneView != null);
                }

                if (sceneView && haveNoParent && !containsModel)
                {
                    var model = SelectionUtility.LastUsedModel;
                    if (!model)
                    {
                        model = OperationsUtility.CreateModelInstanceInScene(selectModel: false);
                        InternalCSGModelManager.EnsureInitialized(model);
                        InternalCSGModelManager.CheckTransformChanged();
                        InternalCSGModelManager.OnHierarchyModified();
                    }
                    var parent = model.transform;

                    int counter = 0;
                    foreach (var obj in visualDragGameObject)
                    {
                        if (!obj)
                        {
                            continue;
                        }
                        if (obj.activeSelf)
                        {
                            obj.transform.SetParent(parent, false);
                            obj.transform.SetSiblingIndex(hoverSiblingIndex + counter);
                            counter++;
                        }
                    }
                }

                if (visualDragGameObject != null)
                {
                    var selection = new List <GameObject>();
                    for (int i = visualDragGameObject.Count - 1; i >= 0; i--)
                    {
                        if (!visualDragGameObject[i])
                        {
                            continue;
                        }
                        if (visualDragGameObject[i].activeSelf)
                        {
                            Undo.RegisterCreatedObjectUndo(visualDragGameObject[i], "Instantiated prefab");
                            selection.Add(visualDragGameObject[i]);
                        }
                        else
                        {
                            GameObject.DestroyImmediate(visualDragGameObject[i]);
                        }
                    }
                    visualDragGameObject = null;

                    if (selection.Count > 0)
                    {
                        UnityEditor.Selection.objects = selection.ToArray();
                    }
                }

                if (sceneView)
                {
                    for (int i = 0; i < SceneView.sceneViews.Count; i++)
                    {
                        var sceneview = SceneView.sceneViews[i] as SceneView;
                        if (!sceneview)
                        {
                            continue;
                        }

                        if (sceneview.camera.pixelRect.Contains(Event.current.mousePosition))
                        {
                            sceneview.Focus();
                        }
                    }
                }
                visualDragGameObject = null;

                InternalCSGModelManager.CheckForChanges(forceHierarchyUpdate: true);
            }
            finally
            {
                InternalCSGModelManager.skipCheckForChanges = false;
                RealtimeCSG.CSGGrid.ForcedGridCenter        = prevForcedGridCenter;
                RealtimeCSG.CSGGrid.ForcedGridRotation      = prevForcedGridRotation;
                RealtimeCSG.CSGGrid.ForceGrid = false;
            }
        }