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!
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. |