Esempio n. 1
0
        public IEnumerator CreateBrushWithBrushMeshAssetWithSurfaceAsset_ModifySurfaceAsset_BrushIsDirty()
        {
            using (var newSurfaceAsset = CSGSurfaceAsset.CreateInstance())
            {
                newSurfaceAsset.LayerUsage = LayerUsageFlags.None;
                var newBrushMeshAsset = BrushMeshAssetFactory.CreateBoxAsset(Vector3.one, newSurfaceAsset);
                var brushGameObject   = EditorUtility.CreateGameObjectWithHideFlags("Brush", HideFlags.None);
                var brush             = brushGameObject.AddComponent <CSGBrush>();
                brush.BrushMeshAsset = newBrushMeshAsset;

                yield return(null);

                CSGBrushMeshAssetManager.Update();
                CSGNodeHierarchyManager.Update();

                newSurfaceAsset.LayerUsage = LayerUsageFlags.Renderable;
                CSGBrushMeshAssetManager.Update();

                Assert.IsTrue(brush.Dirty);
                yield return(null);

                UnityEngine.Object.DestroyImmediate(brushGameObject);
                UnityEngine.Object.DestroyImmediate(newBrushMeshAsset);
            }
        }
 public static void ClearScene()
 {
     defaultScene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene);
     CSGManager.Clear();
     CSGNodeHierarchyManager.Reset();
     CSGNodeHierarchyManager.Update();
 }
Esempio n. 3
0
        public IEnumerator CreateBrushWithBrushContainerAssetWithBrushMaterial_ModifyBrushMaterial_BrushIsDirty()
        {
            using (var newBrushMaterial = ChiselBrushMaterial.CreateInstance())
            {
                newBrushMaterial.LayerUsage = LayerUsageFlags.None;
                var newBrushContainerAsset = CreateBox(Vector3.one, newBrushMaterial);
                var brushGameObject        = EditorUtility.CreateGameObjectWithHideFlags("Brush", HideFlags.None);
                var brush = brushGameObject.AddComponent <ChiselBrush>();
                brush.BrushContainerAsset = newBrushContainerAsset;

                yield return(null);

                ChiselBrushContainerAssetManager.Update();
                CSGNodeHierarchyManager.Update();

                newBrushMaterial.LayerUsage = LayerUsageFlags.Renderable;
                ChiselBrushContainerAssetManager.Update();

                Assert.IsTrue(brush.Dirty);
                yield return(null);

                UnityEngine.Object.DestroyImmediate(brushGameObject);
                UnityEngine.Object.DestroyImmediate(newBrushContainerAsset);
            }
        }
        private static void OnEditorApplicationUpdate()
        {
            // TODO: remove this once we've moved to managed implementation of CSG algorithm
            if (!loggingMethodsRegistered)
            {
                Editors.NativeLogging.RegisterUnityMethods();
                loggingMethodsRegistered = true;
            }

            //Grid.HoverGrid = null;
            CSGNodeHierarchyManager.Update();
            ChiselGeneratedModelMeshManager.UpdateModels();
        }
        void OnGUI()
        {
            CSGNodeHierarchyManager.Update();
            if (styles == null)
            {
                UpdateStyles();
            }

            var selectedTransforms = new HashSet <Transform>();

            foreach (var transform in Selection.transforms)
            {
                selectedTransforms.Add(transform);
            }

            var totalCount = GetVisibleItems(CSGNodeHierarchyManager.sceneHierarchies);

            var itemArea = position;

            itemArea.x = 0;
            itemArea.y = 0;

            var totalRect = position;

            totalRect.x      = 0;
            totalRect.y      = 0;
            totalRect.width  = position.width - kScrollWidth;
            totalRect.height = (totalCount * kItemHeight) + (2 * kPadding);

            var itemRect = position;

            itemRect.x      = 0;
            itemRect.y      = kPadding;
            itemRect.height = kItemHeight;

            m_ScrollPos = GUI.BeginScrollView(itemArea, m_ScrollPos, totalRect);
            {
                Rect visibleArea = itemArea;
                visibleArea.x += m_ScrollPos.x;
                visibleArea.y += m_ScrollPos.y;

                AddFoldOuts(ref itemRect, ref visibleArea, selectedTransforms, CSGNodeHierarchyManager.sceneHierarchies);
            }
            GUI.EndScrollView();
        }
Esempio n. 6
0
        public IEnumerator CreateBrushWithBrushMeshAsset_GetUsedBrushMeshAssets_IsNotNull()
        {
            using (var newSurfaceAsset = CSGSurfaceAsset.CreateInstance())
            {
                var newBrushMeshAsset = BrushMeshAssetFactory.CreateBoxAsset(Vector3.one, newSurfaceAsset);
                var brushGameObject   = EditorUtility.CreateGameObjectWithHideFlags("Brush", HideFlags.None);
                var brush             = brushGameObject.AddComponent <CSGBrush>();
                brush.BrushMeshAsset = newBrushMeshAsset;

                yield return(null);

                CSGBrushMeshAssetManager.Update();
                CSGNodeHierarchyManager.Update();

                Assert.IsNotNull(brush.GetUsedBrushMeshAssets());
                Assert.AreNotEqual(0, brush.GetUsedBrushMeshAssets());
                yield return(null);

                UnityEngine.Object.DestroyImmediate(newBrushMeshAsset);
            }
        }
Esempio n. 7
0
        public IEnumerator CreateBrushWithBrushContainerAsset_GetUsedBrushContainerAssets_IsNotNull()
        {
            using (var newBrushMaterial = ChiselBrushMaterial.CreateInstance())
            {
                var newBrushContainerAsset = CreateBox(Vector3.one, newBrushMaterial);
                var brushGameObject        = EditorUtility.CreateGameObjectWithHideFlags("Brush", HideFlags.None);
                var brush = brushGameObject.AddComponent <ChiselBrush>();
                brush.BrushContainerAsset = newBrushContainerAsset;

                yield return(null);

                ChiselBrushContainerAssetManager.Update();
                CSGNodeHierarchyManager.Update();

                Assert.IsNotNull(brush.GetUsedGeneratedBrushes());
                Assert.AreNotEqual(0, brush.GetUsedGeneratedBrushes());
                yield return(null);

                UnityEngine.Object.DestroyImmediate(newBrushContainerAsset);
            }
        }