Wiki

Case Status
Log In

Wiki

 
Home ยป API Reference»CustomActionEditor
Index
Navigation
Community Wiki

CustomActionEditor

HutongGames.PlayMakerEditor.CustomActionEditor

Extend this class to implement a custom editor for any action.

  • NOTE: This is an Editor script, and should be in an Editor folder.
  • Use the CustomActionEditorAttribute to define the action type to edit.

C# Example:

This example creates a custom editor for Debug Float.

Save it as CustomActionEditorTest.cs in an Editor folder and check out the new Debug Float editor!

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
using UnityEngine;
using UnityEditor;
using HutongGames.PlayMaker.Actions;
using HutongGames.PlayMakerEditor;

[CustomActionEditor(typeof(DebugFloat))]
public class CustomActionEditorTest : CustomActionEditor
{
    public override void OnEnable()
    {
        // Do any expensive initialization stuff here.
        // This is called when the editor is created.
    }

    public override bool OnGUI()
    {
        // If you need to reference the action directly:
        var action = target as DebugFloat;

        // You can draw the full default inspector.

        GUILayout.Label("Default Inspector:", EditorStyles.boldLabel);
        
        var isDirty = DrawDefaultInspector();

        // Or draw individual controls

        GUILayout.Label("Field Controls:", EditorStyles.boldLabel);

        EditField("logLevel");
        EditField("floatVariable");

        // Or add your own controls using any GUILayout method

        GUILayout.Label("Your Controls:", EditorStyles.boldLabel);

        if (GUILayout.Button("Press Me"))
        {
            EditorUtility.DisplayDialog("My Dialog", "Hello", "OK");
            isDirty = true; // e.g., if you change action data
        }

        // OnGUI should return true if you change action data!

        return isDirty || GUI.changed;
    }
}

 

Method Description

void OnEnable()

Use this method for any expensive initialization.

It is called when an FSM is selected.

bool OnGUI()

Use EditorGUILayout and GUILayout controls to build the GUI.

Should return true if the action has been edited.

bool DrawDefaultInspector()

Draw the default inspector for the action type.

Returns true if the action has been edited.

void EditField(string fieldName)

Creates the default editor for the named field.

void OnSceneGUI()

Create interactive gizmos in the scene to edit actions.

See PlayMaker/Actions/Editor for examples.

 

Tags:

Last modified on 5/17/2013 8:29 PM by User.

  • RSS Feed