public void LoadSceneAsync(string sceneName, Action onLoadComplete = null) { CoroutineRunner coroutineRunner = DummyGameObject.AddComponent <CoroutineRunner>(); AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName); coroutineRunner.StartCoroutine(LoadSceneCoroutine(asyncLoad, onLoadComplete)); }
public IEnumerator Should_ThrowArgumentException_When_GameObjectArrayRemainsEmpty() { TargetScript = DummyGameObject.AddComponent <ToggleGameObjects>(); FieldInfo = TargetScript.GetType().BaseType.GetField("_objects", BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo.SetValue(TargetScript, new GameObject[] {}); TestSettings.ExpectException("ArgumentException:"); yield return(null); }
private void AttachTextComponentToDummyGameObject() { TextComponent = DummyGameObject.AddComponent <Text>(); // When working in the editor, this serialized field would be initialized with an empty string TextComponent.text = ""; var type = typeof(TextAdapter); var fieldInfo = type.GetField("_text", BindingFlags.NonPublic | BindingFlags.Instance); fieldInfo?.SetValue(TargetScript, TextComponent); }
public IEnumerator Should_ThrowNullReferenceException_When_AtLeastOneGameObjectArrayElementIsNull() { TargetScript = DummyGameObject.AddComponent <ToggleGameObjects>(); FieldInfo = TargetScript.GetType().BaseType.GetField("_objects", BindingFlags.NonPublic | BindingFlags.Instance); var gameobjects = new GameObject[] { null }; FieldInfo.SetValue(TargetScript, gameobjects); TestSettings.ExpectException("NullReferenceException:"); yield return(null); }
public IEnumerator Should_ContainOnlyActiveGameObjects_When_ScriptFullyInitialized() { TargetScript = DummyGameObject.AddComponent <ToggleGameObjects>(); FieldInfo = TargetScript.GetType().BaseType.GetField("_objects", BindingFlags.NonPublic | BindingFlags.Instance); var gameobjects = new[] { new GameObject(TypeName), new GameObject(TypeName) }; FieldInfo.SetValue(TargetScript, gameobjects); var actual = gameobjects[0].activeSelf && gameobjects[1].activeSelf; Assert.IsTrue(actual); yield return(null); }
public IEnumerator Should_DisableAllGameObjects_When_ToggleMethodWasCalled() { TargetScript = DummyGameObject.AddComponent <ToggleGameObjects>(); FieldInfo = TargetScript.GetType().BaseType.GetField("_objects", BindingFlags.NonPublic | BindingFlags.Instance); var gameobjects = new[] { new GameObject(TypeName), new GameObject(TypeName) }; FieldInfo.SetValue(TargetScript, gameobjects); TargetScript.Toggle(); var actual = gameobjects[0].activeSelf || gameobjects[1].activeSelf; Assert.IsFalse(actual); yield return(null); }
public IEnumerator Should_ContainOnlyActiveComponents_When_ScriptFullyInitialized() { TargetScript = DummyGameObject.AddComponent <ToggleComponents>(); FieldInfo = TargetScript.GetType().BaseType.GetField("_objects", BindingFlags.NonPublic | BindingFlags.Instance); var monoBehaviour1 = new GameObject(TypeName).AddComponent <DefaultBehaviour>(); var monoBehaviour2 = new GameObject(TypeName).AddComponent <DefaultBehaviour>(); var components = new[] { monoBehaviour1, monoBehaviour2 }; FieldInfo.SetValue(TargetScript, components); var propertyInfo = typeof(MonoBehaviour).GetProperty("enabled"); var monobehaviour1Status = (bool)propertyInfo.GetValue(monoBehaviour1, null);; var monobehaviour2Status = (bool)propertyInfo.GetValue(monoBehaviour2, null);; var actual = monobehaviour1Status && monobehaviour2Status; Assert.IsTrue(actual); yield return(null); }
private void AttachTargetScriptToDummyGameObject() { TargetScript = DummyGameObject.AddComponent <TextAdapter>(); // When working in the editor, this serialized field would be initialized with an empty string TargetScript.Id = ""; }
public IEnumerator Should_ThrowNullReferenceException_When_ScriptableObjectWasNotSet() { TestSettings.ExpectNullReferenceException(); DummyGameObject.AddComponent <MainTextureOffsetAnimation>(); yield return(null); }