Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        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;
        }