getPoints() public method

public getPoints ( Vector2 off ) : Vector2[]
off Vector2
return Vector2[]
    public override void OnInspectorGUI()
    {
        GUI.changed = false;
        DrawDefaultInspector();


        // automatically adjust the radius according to width and height
        float lesser = (rb.width > rb.height) ? rb.height : rb.width;

        lesser   /= 2f;
        lesser    = Mathf.Round(lesser * 100f) / 100f;
        rb.radius = EditorGUILayout.Slider("Radius", rb.radius, 0f, lesser);
        rb.radius = Mathf.Clamp(rb.radius, 0f, lesser);

        if (GUILayout.Button("Reset"))
        {
            rb.smoothness       = 15;
            rb.width            = 2;
            rb.height           = 2;
            rb.trapezoid        = 0.5f;
            rb.radius           = 0.5f;
            edgeCollider.offset = Vector2.zero;
        }

        if (GUI.changed || !off.Equals(edgeCollider.offset))
        {
            Vector2[] pts = rb.getPoints(edgeCollider.offset);
            if (pts != null)
            {
                edgeCollider.points = pts;
            }
        }

        off = edgeCollider.offset;
    }
    void OnEnable()
    {
        rb = (RoundedBoxCollider2D)target;

        edgeCollider = rb.GetComponent<EdgeCollider2D>();
        if (edgeCollider == null) {
            rb.gameObject.AddComponent<EdgeCollider2D>();
            edgeCollider = rb.GetComponent<EdgeCollider2D>();
        }

        edgeCollider.points = rb.getPoints(edgeCollider.offset);
    }
    void OnEnable()
    {
        rb = (RoundedBoxCollider2D)target;

        polyCollider = rb.GetComponent <PolygonCollider2D>();
        if (polyCollider == null)
        {
            polyCollider = rb.gameObject.AddComponent <PolygonCollider2D>();
        }

        Vector2[] pts = rb.getPoints();
        if (pts != null)
        {
            polyCollider.points = pts;
        }
    }
Example #4
0
    public override void OnInspectorGUI()
    {
        GUI.changed = false;
        DrawDefaultInspector();


        // automatically adjust the radius according to width and height
        float lesser = (rb.Width > rb.Height) ? rb.Height : rb.Width;

        lesser   /= 2f;
        lesser    = Mathf.Round(lesser * 100f) / 100f;
        rb.Radius = EditorGUILayout.Slider("Radius", rb.Radius, 0f, lesser);
        rb.Radius = Mathf.Clamp(rb.Radius, 0f, lesser);

        rb.advanced = EditorGUILayout.Toggle("Advanced", rb.advanced);
        if (rb.advanced)
        {
            rb.Height = EditorGUILayout.FloatField("Height", rb.Height);
            rb.Width  = EditorGUILayout.FloatField("Width", rb.Width);
        }
        else
        {
            rb.Height = EditorGUILayout.Slider("Height", rb.Height, 1, 25);
            rb.Width  = EditorGUILayout.Slider("Width", rb.Width, 1, 25);
        }

        if (GUILayout.Button("Reset"))
        {
            rb.Smoothness       = 15;
            rb.Width            = 2;
            rb.Height           = 2;
            rb.Trapezoid        = 0.5f;
            rb.Radius           = 0.5f;
            polyCollider.offset = Vector2.zero;
        }

        if (GUI.changed || !off.Equals(polyCollider.offset))
        {
            Vector2[] pts = rb.getPoints();
            if (pts != null)
            {
                polyCollider.points = pts;
            }
        }

        off = polyCollider.offset;
    }
    void OnEnable()
    {
        rb = (RoundedBoxCollider2D)target;

        edgeCollider = rb.GetComponent <EdgeCollider2D>();
        if (edgeCollider == null)
        {
            rb.gameObject.AddComponent <EdgeCollider2D>();
            edgeCollider = rb.GetComponent <EdgeCollider2D>();
        }

        Vector2[] pts = rb.getPoints(edgeCollider.offset);
        if (pts != null)
        {
            edgeCollider.points = pts;
        }
    }
    public override void OnInspectorGUI()
    {
        GUI.changed = false;
        DrawDefaultInspector();

        float lesser = (rb.width > rb.height) ? rb.height : rb.width;

        lesser   /= 2f;
        lesser    = Mathf.Round(lesser * 100f) / 100f;
        rb.radius = Mathf.Clamp(rb.radius, 0f, lesser);

        if (GUI.changed || !off.Equals(polyCollider.offset))
        {
            Vector2[] pts = rb.getPoints();
            if (pts != null)
            {
                polyCollider.points = pts;
            }
        }

        off = polyCollider.offset;
    }