/// <summary> /// Generates an InteractableToggleCollection from radial prefabs /// </summary> private void AssembleInteractableToggleCollection(out InteractableToggleCollection interactableToggleCollection, int numRadials, Vector3 pos) { GameObject toggleCollection = new GameObject("ToggleCollection"); interactableToggleCollection = toggleCollection.AddComponent <InteractableToggleCollection>(); // Instantiate radial prefabs with toggleCollection as the parent for (int i = 0; i < numRadials; i++) { var radial = TestButtonUtilities.InstantiateInteractableFromPath(pos + new Vector3(0.1f, i * 0.1f, 0), Quaternion.identity, RadialPrefabAssetPath); radial.name = "Radial " + i; Assert.IsNotNull(radial); radial.transform.parent = toggleCollection.transform; } interactableToggleCollection.ToggleList = toggleCollection.GetComponentsInChildren <Interactable>(); }
public IEnumerator TestRadialSetPrefab() { var radialSet = TestButtonUtilities.InstantiateInteractableFromPath(Vector3.forward, Quaternion.identity, RadialSetPrefabAssetPath); var firstRadialButton = radialSet.transform.Find("Radial (1)").GetComponent <Interactable>(); var secondRadialButton = radialSet.transform.Find("Radial (2)").GetComponent <Interactable>(); var thirdRadialButton = radialSet.transform.Find("Radial (3)").GetComponent <Interactable>(); var testHand = new TestHand(Handedness.Right); yield return(testHand.Show(Vector3.zero)); Assert.IsTrue(firstRadialButton.IsToggled); Assert.IsFalse(secondRadialButton.IsToggled); Assert.IsFalse(thirdRadialButton.IsToggled); var aBitBack = Vector3.forward * -0.2f; yield return(testHand.MoveTo(secondRadialButton.transform.position)); yield return(testHand.Move(aBitBack)); Assert.IsFalse(firstRadialButton.IsToggled); Assert.IsFalse(firstRadialButton.HasFocus); Assert.IsTrue(secondRadialButton.IsToggled); Assert.IsTrue(secondRadialButton.HasFocus); Assert.IsFalse(thirdRadialButton.IsToggled); Assert.IsFalse(thirdRadialButton.HasFocus); yield return(testHand.MoveTo(thirdRadialButton.transform.position)); yield return(testHand.Move(aBitBack)); Assert.IsFalse(firstRadialButton.IsToggled); Assert.IsFalse(firstRadialButton.HasFocus); Assert.IsFalse(secondRadialButton.IsToggled); Assert.IsFalse(secondRadialButton.HasFocus); Assert.IsTrue(thirdRadialButton.IsToggled); Assert.IsTrue(thirdRadialButton.HasFocus); GameObject.Destroy(radialSet); }