void Awake() { if (instance == null) { instance = this; } else { Debug.LogError("Instance of SelectionRadial already exists in scene. Disabling", this); this.enabled = false; } }
private bool m_GazeOver; // Whether the user is looking at the VRInteractiveItem currently. private void OnEnable() { attachedToggle = GetComponent <Toggle>(); if (this.GetComponent <VRInteractiveItem>() != null) { m_InteractiveItem = this.GetComponent <VRInteractiveItem>(); } else { this.gameObject.AddComponent(typeof(VRInteractiveItem)); Debug.Log("Attaching VR Interactive Script to this GameObject, it's required"); m_InteractiveItem = this.GetComponent <VRInteractiveItem>(); } if (this.GetComponent <BoxCollider>() == null) { this.gameObject.AddComponent(typeof(BoxCollider)); GetComponent <BoxCollider>().size = new Vector3(this.GetComponent <RectTransform>().rect.width, this.GetComponent <RectTransform>().rect.height, 1); Debug.Log("Attaching Box collider to this GameObject, it's required"); } if (Camera.main.gameObject.GetComponent <SelectionRadial>() != null) { m_SelectionRadial = Camera.main.gameObject.GetComponent <SelectionRadial>(); } else { Debug.Log("No SelectionRadial Script attached to the VR Interactive Camera, it's required"); } if (gazeTimeForSelection == 0) { gazeTimeForSelection = 1; } m_InteractiveItem.OnOver += HandleOver; m_InteractiveItem.OnOut += HandleOut; m_SelectionRadial.OnSelectionComplete += HandleSelectionComplete; }
// Use this for initialization void Start() { if (gazeTimeForSelection == 0) { gazeTimeForSelection = 1; //defaults to 1 } if (this.GetComponent <VRInteractiveItem> () != null) { m_InteractiveItem = this.GetComponent <VRInteractiveItem> (); } else { Debug.Log("Attaching VR Interactive Script to this GameObject, it's required"); this.gameObject.AddComponent(typeof(VRInteractiveItem)); m_InteractiveItem = this.GetComponent <VRInteractiveItem> (); } if (this.GetComponent <BoxCollider>() == null) { this.gameObject.AddComponent(typeof(BoxCollider)); GetComponent <BoxCollider> ().size = new Vector3(this.GetComponent <RectTransform> ().rect.width, this.GetComponent <RectTransform> ().rect.height, 1); Debug.Log("Attaching Box collider to this GameObject, it's required"); } if (this.GetComponent <Scrollbar> () != null) { vScale = this.GetComponent <Scrollbar> (); } else { Debug.Log("No Scrollbar component attached to this GameObject, it's required"); } if (this.GetComponent <Scrollbar>().handleRect.gameObject != null) { sliderHandle = this.GetComponent <Scrollbar>().handleRect.gameObject; } else { Debug.Log("No child Handle (GameObject) attached to this GameObject, it's required"); } if (Camera.main.gameObject.GetComponent <SelectionRadial>() != null) { m_SelectionRadial = Camera.main.gameObject.GetComponent <SelectionRadial>(); } else { Debug.Log("No SelectionRadial Script attached to the VR Interactive Camera, it's required"); } if (Camera.main.gameObject.GetComponent <SelectionRadial>() != null) { reticlePosition = Camera.main.gameObject.GetComponent <Reticle>().ReticleTransform; } else { Debug.Log("No Reticle Script attached to the VR Interactive Camera, it's required with it's references"); } //sliderHandle.SetActive(false); }