public IEnumerator CreateSurfaceAsset_SurfaceAddedEventIsCalled() { var hasBeenCalled = false; OnSurfaceAssetDelegate localDelegate = delegate(CSGSurfaceAsset surfaceAsset) { hasBeenCalled = true; }; CSGSurfaceAssetManager.OnSurfaceAssetAdded -= localDelegate; CSGSurfaceAssetManager.OnSurfaceAssetAdded += localDelegate; yield return(null); using (var newSurface = new CSGSurfaceAsset()) { Assert.IsTrue(hasBeenCalled); CSGSurfaceAssetManager.OnSurfaceAssetAdded -= localDelegate; } }
public IEnumerator CreateSurfaceAsset_ChangeUsageFlag_SurfaceChangeEventIsCalled() { using (var newSurface = new CSGSurfaceAsset()) { var hasBeenCalled = false; OnSurfaceAssetDelegate localDelegate = delegate(CSGSurfaceAsset surfaceAsset) { hasBeenCalled = true; }; newSurface.LayerUsage = LayerUsageFlags.None; CSGSurfaceAssetManager.OnSurfaceAssetChanged -= localDelegate; CSGSurfaceAssetManager.OnSurfaceAssetChanged += localDelegate; yield return(null); newSurface.LayerUsage = LayerUsageFlags.Collidable; Assert.IsTrue(hasBeenCalled); CSGSurfaceAssetManager.OnSurfaceAssetChanged -= localDelegate; } }
public IEnumerator CreateSurfaceAsset_ChangePhysicsMaterial_SurfaceChangeEventIsCalled() { using (var newSurface = new CSGSurfaceAsset()) { var newPhysicsMaterial = new PhysicMaterial(); var hasBeenCalled = false; OnSurfaceAssetDelegate localDelegate = delegate(CSGSurfaceAsset surfaceAsset) { hasBeenCalled = true; }; newSurface.PhysicsMaterial = null; CSGSurfaceAssetManager.OnSurfaceAssetChanged -= localDelegate; CSGSurfaceAssetManager.OnSurfaceAssetChanged += localDelegate; yield return(null); newSurface.PhysicsMaterial = newPhysicsMaterial; Assert.IsTrue(hasBeenCalled); CSGSurfaceAssetManager.OnSurfaceAssetChanged -= localDelegate; UnityEngine.Object.DestroyImmediate(newPhysicsMaterial); } }