Beispiel #1
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();
        SFPolygon poly = this.target as SFPolygon;

        EditorGUILayout.HelpBox("When editing the shadow geometry, shift+click to add new points. Command+click or control+click to remove point.", MessageType.Info);
        GUILayout.BeginHorizontal("box");

        if (GUILayout.Button(SFPolygonEditor.inEditMode ? "Stop Editing" : "Edit Shadow Geometry"))
        {
            SFPolygonEditor.inEditMode = !SFPolygonEditor.inEditMode;
            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("Flip Inside-Out"))
        {
            Undo.RecordObjects(this.targets, "Flip Inside-Out");
            foreach (SFPolygon t in this.targets)
            {
                t._FlipInsideOut();
                EditorUtility.SetDirty(t);
            }
        }

        if (poly.GetComponent <PolygonCollider2D> () != null)
        {
            Undo.RecordObjects(this.targets, "Copy from Collider");
            if (GUILayout.Button("Copy from Collider"))
            {
                foreach (SFPolygon t in this.targets)
                {
                    t._CopyVertsFromCollider();
                    EditorUtility.SetDirty(t);
                }
            }
        }

        GUILayout.EndHorizontal();

        PropertyField("_haveShadow");
        PropertyField("_looped");
        PropertyField("_shadowLayers");
        PropertyField("_lightPenetration", (p) => p.floatValue = Math.Max(0.0f, p.floatValue));
        PropertyField("_opacity", (p) => p.floatValue          = Mathf.Clamp01(p.floatValue));

        this.serializedObject.ApplyModifiedProperties();
    }
Beispiel #2
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();
        SFPolygon poly = this.target as SFPolygon;

        EditorGUILayout.HelpBox("When editing the shadow geometry, shift+click to add new points. Command+click or control+click to remove point.", MessageType.Info);
        GUILayout.BeginHorizontal("box");

        if (GUILayout.Button(SFPolygonEditor.inEditMode ? "Stop Editing" : "Edit Shadow Geometry"))
        {
            SFPolygonEditor.inEditMode = !SFPolygonEditor.inEditMode;
            if (Camera.main)
            {
                SFRenderer sfRen = Camera.main.GetComponent <SFRenderer>();
                if (sfRen)
                {
                    if (inEditMode)
                    {
                        preserveShadowSetting = sfRen._shadows;
                        sfRen._shadows        = false;
                    }
                    else
                    {
                        sfRen._shadows = preserveShadowSetting;
                    }
                }
            }
            EditorUtility.SetDirty(target);
        }

        if (GUILayout.Button("Flip Inside-Out"))
        {
            Undo.RecordObjects(this.targets, "Flip Inside-Out");
            foreach (SFPolygon t in this.targets)
            {
                t._FlipInsideOut();
                EditorUtility.SetDirty(t);
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal("box");

        if (poly.GetComponent <Collider2D> () != null)
        {
            Undo.RecordObjects(this.targets, "Copy from Collider");
            if (GUILayout.Button("Copy from Collider"))
            {
                foreach (SFPolygon t in this.targets)
                {
                    t._CopyVertsFromCollider();
                    EditorUtility.SetDirty(t);
                }
            }
        }
        if (poly.GetComponent <SpriteRenderer>() != null)
        {
            Undo.RecordObjects(this.targets, "Copy from Sprite");
            if (GUILayout.Button("Copy from Sprite"))
            {
                foreach (SFPolygon t in this.targets)
                {
                    t._CopyVertsFromSprite();
                    EditorUtility.SetDirty(t);
                }
            }
        }

        GUILayout.EndHorizontal();

        PropertyField("_looped");
        if (poly.GetComponent <CircleCollider2D>() != null)
        {
            PropertyField("circleVertCount");
        }
        //PropertyField("_shadowLayers");

        serializedObject.FindProperty("_shadowLayers").intValue = EditorGUILayout.LayerField("shadowLayers", serializedObject.FindProperty("_shadowLayers").intValue);
        PropertyField("_lightPenetration", (p) => p.floatValue  = Math.Max(0.0f, p.floatValue));
        PropertyField("_opacity", (p) => p.floatValue           = Mathf.Clamp01(p.floatValue));

        this.serializedObject.ApplyModifiedProperties();
    }
Beispiel #3
0
    public override void OnInspectorGUI()
    {
        this.serializedObject.Update();
        SFPolygon poly = this.target as SFPolygon;

        EditorGUILayout.HelpBox("When editing the shadow geometry, shift+click to add new points. Command+click or control+click to remove point.", MessageType.Info);

        // PropertyField("pathCount", (p) => p.intValue = Math.Max(0, p.intValue));
        PropertyField("_activePath", (p) => p.intValue = Math.Min(Math.Max(-1, p.intValue), poly.pathCount - 1));
        poly.pathCount = Math.Max(1, EditorGUILayout.DelayedIntField("Path Count", poly.pathCount));

        GUILayout.BeginHorizontal("box"); {
            if (GUILayout.Button("<"))
            {
                foreach (SFPolygon t in this.targets)
                {
                    t.activePath = Math.Max(0, t.activePath - 1);
                    EditorUtility.SetDirty(t);
                }
            }

            if (GUILayout.Button(">"))
            {
                foreach (SFPolygon t in this.targets)
                {
                    t.activePath = Math.Min(t.pathCount - 1, t.activePath + 1);
                    EditorUtility.SetDirty(t);
                }
            }

            if (GUILayout.Button("All Paths"))
            {
                foreach (SFPolygon t in this.targets)
                {
                    t.activePath = -1;
                    EditorUtility.SetDirty(t);
                }
                SFPolygonEditor.inEditMode = false;
            }

            if (poly.GetComponent <PolygonCollider2D>() || poly.GetComponent <BoxCollider2D>())
            {
                Undo.RecordObjects(this.targets, "Copy from Collider");
                if (GUILayout.Button("Copy from Collider"))
                {
                    foreach (SFPolygon t in this.targets)
                    {
                        t._CopyFromCollider();
                        EditorUtility.SetDirty(t);
                    }
                }
            }
        } GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal("box"); {
            if (GUILayout.Button(SFPolygonEditor.inEditMode ? "Stop Editing" : "Edit Path"))
            {
                SFPolygonEditor.inEditMode = !SFPolygonEditor.inEditMode;
                EditorUtility.SetDirty(target);
            }

            if (GUILayout.Button("Flip Inside-Out"))
            {
                Undo.RecordObjects(this.targets, "Flip Inside-Out");
                foreach (SFPolygon t in this.targets)
                {
                    t._FlipInsideOut(t.activePath);
                    EditorUtility.SetDirty(t);
                }
            }
        } GUILayout.EndHorizontal();

        PropertyField("_looped");
        PropertyField("_shadowLayers");
        PropertyField("_lightPenetration", (p) => p.floatValue = Mathf.Max(0.0f, p.floatValue));
        PropertyField("_opacity", (p) => p.floatValue          = Mathf.Clamp01(p.floatValue));

        this.serializedObject.ApplyModifiedProperties();
    }