Exemple #1
0
    private static void DrawLineWindows(Vector2 pointA, Vector2 pointB, Color color, float width, bool antiAlias)
    {
        Color     color2 = GUI.color;
        Matrix4x4 matrix = GUI.matrix;

        if (antiAlias)
        {
            width *= 3f;
        }
        float   num       = Vector3.Angle(pointB - pointA, Vector2.right) * (float)((pointA.y > pointB.y) ? -1 : 1);
        float   magnitude = (pointB - pointA).magnitude;
        Vector3 vector    = new Vector3(pointA.x, pointA.y, 0f);

        GUI.color  = color;
        GUI.matrix = Drawing_tc.translationMatrix(vector) * GUI.matrix;
        GUIUtility.ScaleAroundPivot(new Vector2(magnitude, width), new Vector2(-0.5f, 0f));
        GUI.matrix = Drawing_tc.translationMatrix(-vector) * GUI.matrix;
        GUIUtility.RotateAroundPivot(num, new Vector2(0f, 0f));
        GUI.matrix = Drawing_tc.translationMatrix(vector + new Vector3(width / 2f, -magnitude / 2f) * Mathf.Sin(num * 0.0174532924f)) * GUI.matrix;
        GUI.DrawTexture(new Rect(0f, 0f, 1f, 1f), antiAlias ? Drawing_tc.adLineTex : Drawing_tc.lineTex);
        GUI.matrix = matrix;
        GUI.color  = color2;
    }
Exemple #2
0
    private static void DrawLineMac(Vector2 pointA, Vector2 pointB, Color color, float width, bool antiAlias)
    {
        Color     color2 = GUI.color;
        Matrix4x4 matrix = GUI.matrix;
        float     num    = width;

        if (antiAlias)
        {
            width *= 3f;
        }
        float num2      = Vector3.Angle(pointB - pointA, Vector2.right) * (float)((pointA.y > pointB.y) ? -1 : 1);
        float magnitude = (pointB - pointA).magnitude;

        if (magnitude > 0.01f)
        {
            Vector3 vector = new Vector3(pointA.x, pointA.y, 0f);
            Vector3 b      = new Vector3((pointB.x - pointA.x) * 0.5f, (pointB.y - pointA.y) * 0.5f, 0f);
            Vector3 zero   = Vector3.zero;
            if (antiAlias)
            {
                zero = new Vector3(-num * 1.5f * Mathf.Sin(num2 * 0.0174532924f), num * 1.5f * Mathf.Cos(num2 * 0.0174532924f));
            }
            else
            {
                zero = new Vector3(-num * 0.5f * Mathf.Sin(num2 * 0.0174532924f), num * 0.5f * Mathf.Cos(num2 * 0.0174532924f));
            }
            GUI.color  = color;
            GUI.matrix = Drawing_tc.translationMatrix(vector) * GUI.matrix;
            GUIUtility.ScaleAroundPivot(new Vector2(magnitude, width), new Vector2(-0.5f, 0f));
            GUI.matrix = Drawing_tc.translationMatrix(-vector) * GUI.matrix;
            GUIUtility.RotateAroundPivot(num2, Vector2.zero);
            GUI.matrix = Drawing_tc.translationMatrix(vector - zero - b) * GUI.matrix;
            GUI.DrawTexture(new Rect(0f, 0f, 1f, 1f), (!antiAlias) ? Drawing_tc.lineTex : Drawing_tc.adLineTex);
        }
        GUI.matrix = matrix;
        GUI.color  = color2;
    }