Esempio n. 1
0
        /// <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);
                }
            }
        }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
        /// <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>());
        }