示例#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());

            yield return(new WaitForEndOfFrame());

            if (SetColliderAuto)
            {
                BoxCollider box = GetComponent <BoxCollider>();
                box        = VRUIBoxColliderSetup.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);
                }
            }

            _scrollableSetup.CheckContentStatus(viewport, content);
            _boxColliderSetup = true;
        }
示例#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());

            yield return(new WaitForEndOfFrame());

            VRUIBoxColliderSetup.CheckBoxColliderSize(GetComponent <BoxCollider>(), GetComponent <RectTransform>());
        }
示例#3
0
        /// <summary>
        /// Set the BoxCollider if the SetColliderAuto is at true
        /// </summary>
        /// <returns></returns>
        private IEnumerator <WaitForEndOfFrame> SetupBoxCollider()
        {
            yield return(new WaitForEndOfFrame());

            if (SetColliderAuto)
            {
                VRUIBoxColliderSetup.CheckBoxColliderSize(GetComponent <BoxCollider>(), GetComponent <RectTransform>());
            }

            _boxColliderSetup = true;
        }
示例#4
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());

            yield return(new WaitForEndOfFrame());

            var boxCollider = GetComponent <BoxCollider>();
            var rectTrans   = GetComponent <RectTransform>();

            if (boxCollider != null && rectTrans != null)
            {
                VRUIBoxColliderSetup.CheckBoxColliderSize(boxCollider, rectTrans);
            }
        }