/// <summary> /// Start a coroutine that wait for the second frame to set the BoxCollider /// </summary> /// <returns></returns> IEnumerator <WaitForEndOfFrame> SetupBoxCollider() { yield return(new WaitForEndOfFrame()); if (SetColliderAuto) { BoxCollider box = GetComponent <BoxCollider>(); box = VRUISetupHelper.CheckBoxColliderSize(box, GetComponent <RectTransform>()); box.center = Vector3.zero; if (vertical) { var barCollider = verticalScrollbar.GetComponent <BoxCollider>(); float x = (box.size.x - barCollider.size.x); box.size = new Vector3(x, box.size.y, box.size.z); box.center = new Vector3(-barCollider.size.x / 2, box.center.y, box.center.z + 0.1f); } if (horizontal) { var barCollider = horizontalScrollbar.GetComponent <BoxCollider>(); float y = (box.size.y - barCollider.size.y); box.size = new Vector3(box.size.x, y, box.size.z); box.center = new Vector3(box.center.x, barCollider.size.y / 2, box.center.z + 0.1f); } } }
private void CheckDevice(OnSetupVRReady info) { if (OnSetupVRReady.IsCallbackRegistered(CheckDevice)) { OnSetupVRReady.Listeners -= CheckDevice; } if (VRDF_Components.DeviceLoaded != Core.SetupVR.EDevice.SIMULATOR || VRUISetupHelper.ShouldRegisterForSimulator(this)) { OnVRClickerStartClicking.Listeners += CheckClickedObject; } }
/// <summary> /// Setup the BoxCOllider size and center by colling the NotScrollableSetup method CheckBoxColliderSize. /// We use a coroutine and wait for the end of the first frame as the element cannot be correctly setup on the first frame /// </summary> /// <returns></returns> IEnumerator <WaitForEndOfFrame> SetupBoxCollider() { yield return(new WaitForEndOfFrame()); var boxCollider = GetComponent <BoxCollider>(); var rectTrans = GetComponent <RectTransform>(); if (boxCollider != null && rectTrans != null) { VRUISetupHelper.CheckBoxColliderSize(boxCollider, rectTrans); } }
protected override void Awake() { base.Awake(); if (Application.isPlaying) { if (LaserClickable && VRUISetupHelper.ShouldRegisterForSimulator(this)) { OnVRClickerStartClicking.Listeners += CheckClickedObject; } if (ControllerClickable) { GetComponent <BoxCollider>().isTrigger = true; } SetInputFieldReferences(); } }
/// <summary> /// Setup the BoxCOllider size and center by colling the NotScrollableSetup method CheckBoxColliderSize. /// We use a coroutine and wait for the end of the first frame as the element cannot be correctly setup on the first frame /// </summary> /// <returns></returns> IEnumerator <WaitForEndOfFrame> SetupBoxCollider() { yield return(new WaitForEndOfFrame()); VRUISetupHelper.CheckBoxColliderSize(GetComponent <BoxCollider>(), GetComponent <RectTransform>()); }