예제 #1
0
        public static void DrawArrowPointingAt(Rect rect)
        {
            Vector2   v        = new Vector2(UI.screenWidth, UI.screenHeight) / 2f;
            float     angle    = Mathf.Atan2(rect.center.x - v.x, v.y - rect.center.y) * 57.29578f;
            Vector2   vector   = new Bounds(rect.center, rect.size).ClosestPoint(v);
            Rect      position = new Rect(vector + Vector2.left * ArrowTex.width * 0.5f, new Vector2(ArrowTex.width, ArrowTex.height));
            Matrix4x4 matrix   = GUI.matrix;

            GUI.matrix = Matrix4x4.identity;
            Vector2 center = GUIUtility.GUIToScreenPoint(vector);

            GUI.matrix = matrix;
            UI.RotateAroundPivot(angle, center);
            GUI.DrawTexture(position, ArrowTex);
            GUI.matrix = matrix;
        }