public IEnumerator CreateBrushMeshAssetWithSurfaceAsset_ModifySurfaceAssetPhysicsMaterial_InstanceChangedEventIsCalled() { var newPhysicsMaterial = new PhysicMaterial(); var hasBeenCalled = false; OnBrushMeshAssetDelegate localDelegate = delegate(CSGBrushMeshAsset brushMeshAsset) { hasBeenCalled = true; }; using (var newSurfaceAsset = CSGSurfaceAsset.CreateInstance()) { newSurfaceAsset.PhysicsMaterial = null; var newBrushMeshAsset = BrushMeshAssetFactory.CreateBoxAsset(Vector3.one, newSurfaceAsset); yield return(null); CSGBrushMeshAssetManager.OnBrushMeshInstanceChanged -= localDelegate; CSGBrushMeshAssetManager.OnBrushMeshInstanceChanged += localDelegate; newSurfaceAsset.PhysicsMaterial = newPhysicsMaterial; yield return(null); Assert.IsTrue(hasBeenCalled); CSGBrushMeshAssetManager.OnBrushMeshInstanceChanged -= localDelegate; UnityEngine.Object.DestroyImmediate(newBrushMeshAsset); UnityEngine.Object.DestroyImmediate(newPhysicsMaterial); } }
public IEnumerator CreateBrushMeshAsset_Destroy_InstanceDestroyedEventIsCalled() { var hasBeenCalled = false; OnBrushMeshAssetDelegate localDelegate = delegate(CSGBrushMeshAsset brushMeshAsset) { hasBeenCalled = true; }; using (var newSurfaceAsset = CSGSurfaceAsset.CreateInstance()) { var newBrushMeshAsset = BrushMeshAssetFactory.CreateBoxAsset(Vector3.one, newSurfaceAsset); CSGBrushMeshAssetManager.OnBrushMeshInstanceDestroyed -= localDelegate; CSGBrushMeshAssetManager.OnBrushMeshInstanceDestroyed += localDelegate; UnityEngine.Object.DestroyImmediate(newBrushMeshAsset); yield return(null); Assert.IsTrue(hasBeenCalled); CSGBrushMeshAssetManager.OnBrushMeshInstanceDestroyed -= localDelegate; } }