Example #1
0
    public override void OnInspectorGUI()
    {
        LBoxCollider2D obj = serializedObject.targetObject as LBoxCollider2D;

        obj.center = EditorGUILayout.Vector2Field("Center", obj.center);
        obj.size   = EditorGUILayout.Vector2Field("Size", obj.size);
        serializedObject.ApplyModifiedProperties();
    }
Example #2
0
    protected override void OnEnable()
    {
        base.OnEnable();
        LBoxCollider2D obj = serializedObject.targetObject as LBoxCollider2D;

        if (obj != null &&
            obj.gameObject.renderer != null &&
            obj.size.Equals(Vector2.one))
        {
            Vector3 size = obj.gameObject.renderer.bounds.size;
            obj.size = new Vector2(size.x / obj.transform.localScale.x, size.y / obj.transform.localScale.y);
        }
    }
Example #3
0
    protected override void OnDrawSceneGUI()
    {
        base.OnDrawSceneGUI();
        LBoxCollider2D obj = serializedObject.targetObject as LBoxCollider2D;

        Vector2[] localVertics = new Vector2[4];
        Vector2   size2        = obj.size / 2;

        localVertics[0] = obj.center - size2;
        localVertics[1] = obj.center + new Vector2(size2.x, -size2.y);
        localVertics[2] = obj.center + size2;
        localVertics[3] = obj.center + new Vector2(-size2.x, size2.y);
        Vector3[] vertics = System.Array.ConvertAll <Vector2, Vector3>(localVertics, (Vector2 each) => obj.transform.TransformPoint(each));
        Handles.color = LineColor;
        Handles.DrawAAPolyLine(LineWidth, vertics);
        Handles.DrawAAPolyLine(LineWidth, new Vector3[] { vertics[0], vertics[3] });
        Handles.color = Color.white;
    }