Exemple #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        = _UISetup.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);
                }

                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);
                }
            }

            _boxColliderSetup = true;
        }
Exemple #2
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 = _uiSetup.CheckBoxColliderSize(box, GetComponent <RectTransform>());
            }
            _boxColliderSetup = true;
        }