public IEnumerator AddAndRemoveTrainingProperties() { // Given a ISceneObject. // Required for ColliderWithTriggerProperty SceneObject.GameObject.AddComponent <BoxCollider>().isTrigger = true; // When adding a list of ISceneObjectProperty to the ISceneObject. yield return(AddTrainingProperties()); foreach (Component propertyComponent in SceneObject.GameObject.GetComponents(typeof(TrainingSceneObjectProperty))) { // When removing a ISceneObjectProperty from the ISceneObject. SceneObject.RemoveTrainingProperty(propertyComponent); yield return(null); // Then assert that the ISceneObjectProperty is no longer part of ISceneObject. Assert.That(SceneObject.GameObject.GetComponent(propertyComponent.GetType()) == null); } int totalOfAddedProperties = SceneObject.Properties.Count; // Then assert that all ISceneObjectProperty were removed. Assert.AreEqual(0, totalOfAddedProperties); }
private static void RemoveTrainingProperties() { Component[] trainingProperties = Selection.activeGameObject.GetComponents(typeof(TrainingSceneObjectProperty)); ISceneObject sceneObject = Selection.activeGameObject.GetComponent(typeof(ISceneObject)) as ISceneObject; foreach (Component trainingProperty in trainingProperties) { sceneObject.RemoveTrainingProperty(trainingProperty, true); } }
private void UndoSceneObjectAutomaticSetup(GameObject selectedSceneObject, Type valueType, bool hadTrainingComponent, Component[] alreadyAttachedProperties) { ISceneObject sceneObject = selectedSceneObject.GetComponent <TrainingSceneObject>(); if (typeof(ISceneObjectProperty).IsAssignableFrom(valueType)) { sceneObject.RemoveTrainingProperty(valueType, true, alreadyAttachedProperties); } if (hadTrainingComponent == false) { Object.DestroyImmediate((TrainingSceneObject)sceneObject); } isUndoOperation = true; }