private void CreateButton(ButtonTemplate template, ButtonIconProfile customIconProfile) { if (template.IsEmpty) { return; } switch (template.Type) { case ButtonTypeEnum.Custom: NumDefaultButtons++; break; case ButtonTypeEnum.Adjust: NumDefaultButtons++; break; case ButtonTypeEnum.Done: NumManipulationButtons++; break; case ButtonTypeEnum.Remove: NumManipulationButtons++; NumDefaultButtons++; break; case ButtonTypeEnum.Hide: NumDefaultButtons++; break; case ButtonTypeEnum.Show: numHiddenButtons++; break; default: throw new ArgumentOutOfRangeException(); } GameObject newButton = Instantiate(SquareButtonPrefab, buttonParent); newButton.name = template.Name; newButton.transform.localPosition = Vector3.zero; newButton.transform.localRotation = Quaternion.identity; AppBarButton mtb = newButton.AddComponent <AppBarButton>(); mtb.Initialize(this, template, customIconProfile); }
protected override void InputClicked(GameObject obj, InputClickedEventData eventData) { if (Time.time < lastTimeTapped + coolDownTime) { return; } lastTimeTapped = Time.time; base.InputClicked(obj, eventData); switch (obj.name) { case "Remove": // Destroy the target object, Bounding Box, Bounding Box Rig and App Bar boundingBox.Target.GetComponent <BoundingBoxRig>().Deactivate(); Destroy(boundingBox.Target.GetComponent <BoundingBoxRig>()); Destroy(boundingBox.Target); Destroy(gameObject); break; case "Adjust": // Make the bounding box active so users can manipulate it State = AppBarStateEnum.Manipulation; // Activate BoundingBoxRig boundingBox.Target.GetComponent <BoundingBoxRig>().Activate(); break; case "Hide": // Make the bounding box inactive and invisible State = AppBarStateEnum.Hidden; break; case "Show": State = AppBarStateEnum.Default; // Deactivate BoundingBoxRig boundingBox.Target.GetComponent <BoundingBoxRig>().Deactivate(); break; case "Done": State = AppBarStateEnum.Default; // Deactivate BoundingBoxRig boundingBox.Target.GetComponent <BoundingBoxRig>().Deactivate(); break; case "TogglePlay": State = AppBarStateEnum.Default; // Play / Pause Animation of model BlendShapeAnimation blendShapeAnimation = boundingBox.Target.GetComponent <BlendShapeAnimation>(); blendShapeAnimation.TogglePlay(); // Switch icon to Play <=> Pause AppBarButton toggleButton = buttonParent.GetComponentsInChildren <AppBarButton>().Single(b => b.name == "TogglePlay"); ButtonTemplate buttonTmpl = buttons.Single(b => b.Name == "TogglePlay"); buttonTmpl.Icon = blendShapeAnimation.Playing ? "PauseIcon" : "PlayIcon"; toggleButton.Initialize(this, buttonTmpl, null); break; default: break; } }