public IEnumerator TestDisabledOnStart() { // Instantiate model_pushbutton prefab but with enabled on start false TestButtonUtilities.InstantiatePressableButtonPrefab( new Vector3(0.025f, 0.05f, 0.5f), TestButtonUtilities.DefaultRotation, DisabledOnStartPrefabAssetPath, "Cylinder", out Interactable interactable, out Transform pressButtonCylinder); // Subscribe to interactable's on click so we know the click went through bool wasClicked = false; interactable.OnClick.AddListener(() => { wasClicked = true; }); Vector3 targetStartPosition = pressButtonCylinder.localPosition; // // Test starting as disabled // yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, pressButtonCylinder, false)); Assert.False(wasClicked, "Interactable was clicked."); // // Test when enabled // interactable.IsEnabled = true; yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, pressButtonCylinder, true)); Assert.True(wasClicked, "Interactable was not clicked."); // Cleanup GameObject.Destroy(interactable.gameObject); }
public IEnumerator TestHandInputOnPrefab() { TestButtonUtilities.InstantiatePressableButtonPrefab( new Vector3(0.025f, 0.05f, 0.5f), TestButtonUtilities.DefaultRotation, TestButtonUtilities.DefaultInteractablePrefabAssetPath, "Cylinder", out Interactable interactable, out Transform translateTargetObject); // Subscribe to interactable's on click so we know the click went through bool wasClicked = false; interactable.OnClick.AddListener(() => { wasClicked = true; }); Vector3 targetStartPosition = translateTargetObject.localPosition; yield return(TestButtonUtilities.TestClickPushButton(interactable.transform, targetStartPosition, translateTargetObject)); Assert.True(wasClicked, "Interactable was not clicked."); //Cleanup GameObject.Destroy(interactable.gameObject); }