Beispiel #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);
            }
        }
Beispiel #2
0
        public IEnumerator CreateBrushMeshAsset_IsPartOfManager()
        {
            var newBrushMeshAsset = ScriptableObject.CreateInstance <CSGBrushMeshAsset>();

            yield return(null);

            CSGBrushMeshAssetManager.Update();

            //Assert.False(CSGBrushMeshAssetManager.IsInUpdateQueue(newBrushMeshAsset)); // should already be done
            Assert.True(CSGBrushMeshAssetManager.IsRegistered(newBrushMeshAsset));
            UnityEngine.Object.DestroyImmediate(newBrushMeshAsset);
        }
Beispiel #3
0
        public IEnumerator CreateBrushMeshAsset_HasValidInstance()
        {
            using (var newSurfaceAsset = CSGSurfaceAsset.CreateInstance())
            {
                var newBrushMeshAsset = BrushMeshAssetFactory.CreateBoxAsset(Vector3.one, newSurfaceAsset);
                Assert.IsFalse(newBrushMeshAsset.Instances != null && newBrushMeshAsset.Instances[0].Valid);
                yield return(null);

                CSGBrushMeshAssetManager.Update();

                //Assert.False(CSGBrushMeshAssetManager.IsInUpdateQueue(newBrushMeshAsset)); // should already be done
                Assert.IsTrue(newBrushMeshAsset.Instances != null && newBrushMeshAsset.Instances[0].Valid);
                UnityEngine.Object.DestroyImmediate(newBrushMeshAsset);
            }
        }
Beispiel #4
0
        public IEnumerator CreateBrushMeshAsset_SetDirty_IsDirty()
        {
            var newBrushMeshAsset = ScriptableObject.CreateInstance <CSGBrushMeshAsset>();

            yield return(null);

            CSGBrushMeshAssetManager.Update();

            //Assert.False(CSGBrushMeshAssetManager.IsInUpdateQueue(newBrushMeshAsset));
            //Assert.False(CSGBrushMeshAssetManager.IsInUnregisterQueue(newBrushMeshAsset));
            Assert.True(CSGBrushMeshAssetManager.IsRegistered(newBrushMeshAsset));
            CSGBrushMeshAssetManager.SetDirty(newBrushMeshAsset);
            //Assert.True(CSGBrushMeshAssetManager.IsInUpdateQueue(newBrushMeshAsset));
            Assert.True(CSGBrushMeshAssetManager.IsDirty(newBrushMeshAsset));

            UnityEngine.Object.DestroyImmediate(newBrushMeshAsset);
        }
Beispiel #5
0
        public IEnumerator CreateBrushMeshAsset_Unregister_DoesNotHaveValidInstance()
        {
            using (var newSurfaceAsset = CSGSurfaceAsset.CreateInstance())
            {
                var newBrushMeshAsset = BrushMeshAssetFactory.CreateBoxAsset(Vector3.one, newSurfaceAsset);
                Assert.IsFalse(newBrushMeshAsset.Instances != null && newBrushMeshAsset.Instances[0].Valid);
                yield return(null);

                CSGBrushMeshAssetManager.Update();

                CSGBrushMeshAssetManager.Unregister(newBrushMeshAsset);
                yield return(null);

                CSGBrushMeshAssetManager.Update();

                //Assert.False(CSGBrushMeshAssetManager.IsInUpdateQueue(newBrushMeshAsset)); // should already be done
                Assert.IsFalse(newBrushMeshAsset.Instances != null && newBrushMeshAsset.Instances[0].Valid);
            }
        }
Beispiel #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);
            }
        }