/// <summary>
        /// Global static helper method for finding the position of the mouse on a canvas.
        /// </summary>
        public static Vector3 GetPointerPosOnCanvas(Canvas canvas, Vector2 pointerPos)
        {
            if (canvas.renderMode == RenderMode.ScreenSpaceCamera)
            {
                Vector2 pos;
                RectTransformUtility.ScreenPointToLocalPointInRectangle(canvas.transform as RectTransform, pointerPos, canvas.worldCamera, out pos);
                return(canvas.transform.TransformPoint(pos));
            }
            else if (canvas.renderMode == RenderMode.ScreenSpaceOverlay)
            {
                return(PointerUtility.GetPosition());
            }
            else
            {
                Vector3 globalMousePos;
                if (RectTransformUtility.ScreenPointToWorldPointInRectangle(canvas.transform as RectTransform, PointerUtility.GetPosition(), canvas.worldCamera, out globalMousePos))
                {
                    return(globalMousePos);
                }
            };

            return(Vector2.zero);
        }
 void Update()
 {
     transform.position = GetPointerPosOnCanvas(canvas, PointerUtility.GetPosition());
 }