Custom Action Editors
You can override the default action editor with a custom editor.
The custom action editor replaces the parameters section and must use UI Toolkit.
To build a custom action editor:
- Override
CustomActionEditor. - Add a
CustomActionEditorAttributeto target an action type. - Implement
BuildGUIto build the custom editor.
Minimal example
This example is equivalent to the default action editor:
using HutongGames.PlayMaker.Editor;
namespace MyNamespace
{
[CustomActionEditor(typeof(MyCustomAction))]
public class MinimalCustomActionEditor : CustomActionEditor
{
public override void BuildGUI()
{
BuildDefaultGUI();
}
}
}
BuildDefaultGUI
Call this to build the default action editor.
This is useful if you just want to augment the default editor in some way. For example, to add some extra tools, or debug information.
AddField
Use AddField(string fieldName) to add a specific field to the editor.
For example, to add the _name field:
This lets you add specific fields as needed.
Root VisualElement
Custom elements should be added to the Root visual element.
For example, to add a help box:
public override void BuildGUI()
{
BuildDefaultGUI();
Root.Add(new HelpBox("Be careful!", HelpBoxMessageType.Warning));
}
Properties
The base CustomActionEditor class provides some useful properties:
| Property | Description |
|---|---|
Target |
The action targeted by the editor. You can cast this to the action type you are editing. |
TargetProperty |
The SerializeProperty for the action. Use this to edit the action. |
Methods
The base CustomActionEditor class provides some useful methods:
| Method | Description |
|---|---|
void BuildDefaultGUI() |
Builds the default action editor for the target action. |
VisualElement AddField(string fieldName) |
Adds a specific field to the editor. Use the serialized name of the field. Returns the VisualElement added to the Root. |
void UpdateErrors() |
Call this after editing to update error callouts. Most of the time this is handled automatically, but there may be situations where you need to call this. |
void Add(VisualElement element) |
Adds a visual element to the Root. Shortcut for Root.Add() |