Example #1
0
        /// <summary>
        /// Determine if the next mouse pos would result in the rect staying within screenbounds
        /// </summary>
        /// <param name="newMousePos"></param>
        /// <param name="fourCornerArray"></param>
        /// <returns></returns>
        private bool DetermineValidMousepos(Vector2 newMousePos, out Vector2[] fourCornerArray)
        {
            var diff = lastFrameMousePos - newMousePos;

            fourCornerArray = lastFrameRectCorners;
            for (int i = 0; i < 4; i++)
            {
                fourCornerArray[i] = new Vector2(
                    fourCornerArray[i].x - diff.x,
                    fourCornerArray[i].y - diff.y);
            }
            ;
            return(RectTransformUtilities.CornersAreWithinScreenBounds(fourCornerArray));
        }