Attributes
This page describes all the attributes that can be used to customize actions.
Type Attributes
| Attribute | Description |
|---|---|
| ActionCategory | Sets the action's category in the Action Browser. |
| ActionDescription | Sets the description used in the Action Browser and Action Editor. |
| ConvertibleGroup | Groups actions for quick swapping in the Action Editor. |
| HasSceneGUI | Indicates the action has OnSceneGUI editing. See Scene GUI Drawer. |
Field Attributes
| Attribute | Description |
|---|---|
| Tooltip | Used as action parameter tooltip. |
| Optional | Marks an action parameter as optional. By default, fields are required. |
| DefaultValue | Sets the default value when an action is created or reset. |
| CanBeNullOrEmpty | Allows a required field to be null or empty. |
| ConvertibleName | Used to match fields in a ConvertibleGroup when names differ. |
| ActionTarget | Indicates a field is the "target" for drag-and-drop menus. |
| RequiredComponent | Specifies a required component for the field. |
| ActionHeader | Shows a header above a field in the editor, like Unity's HeaderAttribute. |
| Note | Shows a HelpBox above a field for prominent info. |
| DisplayOrder | Overrides field order in the UI. Lower numbers appear first. |
Variable Field Attributes
| Attribute | Description |
|---|---|
| OwnerDefaultValue | Field defaults to Owner |
| NotOwnerDefaultValue | Field should NOT default to Owner |
| WriteOnly | Marks a field as write only. |
| VarRange | Like Unity's RangeAttribute but for variable fields. |
| VarSlider | Displays a slider for variable fields. Values can exceed the slider range. |
| HideDebugValue | Hides the debug value for this field. See Debug Variable Values. |
| DefaultName | Sets a custom name when auto-adding a variable or event. |
| LayerValue | Marks an IntegerVar as a Layer value and shows the appropriate UI. |
| TagValue | Marks a StringVar as a Tag and shows the appropriate UI. |
| MatchType | Ensures the field matches the type of another field. |
| BaseType | Base type assignable to a variable field. |
Event Field Attributes
| Attribute | Description |
|---|---|
| GlobalEvent | Marks an event field as requiring a Global Event. |
| BroadcastEvent | Marks an event field as one that will be broadcast. |
| EventNotSent | Indicates the event is not sent. |
| DisableEventNotUsed-InTransitionsError | Disables error check on an EventRef field if the event is not sent. |
List Field Attributes
| Attribute | Description |
|---|---|
| ArrayElementLabel | Overrides the label for array/list elements in the UI. |
| ArrayElementTooltip | Tooltip for individual array/list elements. |
| HideArrayLabels | Hides element labels in the UI. |
Details
Below you'll find detailed descriptions for each attribute.
ActionCategory
Sets the action's category in the Action Browser.
| Parameter | Type | Description |
|---|---|---|
| name | string | Name of an existing or new category. Use "/" to nest categories.HutongGames.PlayMaker.Category defines common categories. |
ActionDescription
Sets the description used in the Action Browser and Action Editor.
| Parameter | Type | Description |
|---|---|---|
| summary | string | A short summary of the action. |
| details | string | (Optional) More detail shown in the Action Browser. |
ConvertibleGroup
A named group of actions that are all swappable in the Action Editor.
For example, OnCollisionEnter and OnCollisionExit actions are both in the "OnCollision" group.
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the convertible group. |
HasSceneGUI
Indicates that an Action has OnSceneGUI editing.
See Scene GUI Drawer
Tooltip
Describes an action field. Shown in rollover tooltips and summaries.
| Parameter | Type | Description |
|---|---|---|
| tooltip | string | A short description of the action field. |
Optional
Marks an action parameter as optional.
Upgrade Note
Action fields are required unless marked as optional.
This is a change from PM1 where parameters where optional unless marked as required.
WriteOnly
Marks an action field as write only. The field should be a Ref: FloatRef, StringRef, etc.
WriteOnly means you can only select writable variables for the parameter.
DefaultValue
Defines the default value of an action field when an action is created or reset. Otherwise the field uses the default value for the data type (0 for float, null for GameObject, etc.)
The value can be:
- A constant value compatible with the field type:
0,1f,"Hello"... - A string representing a named value:
"Vector3.up","Vector2.one","Color.red","Quaternion.identity" - A string starting with
~, representing a named PlayMaker value:"~MainCamera","~Vector3Up" - An enum name as a string for enum fields:
"Z","UseGlobal" - A comma-separated value list for some struct types:
"0,1","0,1,2","0,0,10,20" - A
typeof(...)value for supported type-reference fields DefaultValueAttribute.Noneto default a field toNone
Tip
Because constants and globals are just assets in the project, you can include project specific default values in custom actions.
Supported Formats
Here are the main formats supported by DefaultValue:
| Format | Example | Notes |
|---|---|---|
| Primitive or literal value | [DefaultValue(1f)] |
Works for compatible literal values such as int, float, bool, and strings. |
| Named built-in value | [DefaultValue("Vector3.up")] |
Useful for vectors, colors, quaternions, and similar values. |
| Named PlayMaker value | [DefaultValue("~MainCamera")] |
Uses a named PlayMaker value instead of a literal constant. |
| Enum value by name | [DefaultValue("Z")] |
Useful when the field type is an enum. |
| Comma-separated struct value | [DefaultValue("0,0,10,20")] |
Supported for some multi-value structs. |
| Type reference | [DefaultValue(typeof(MyBlockType))] |
Used for supported type-reference or block fields. |
| None sentinel | [DefaultValue(DefaultValueAttribute.None)] |
Sets the field to None instead of a concrete value. |
Named Values
Named values are string defaults that resolve to known values at edit time.
Common examples include:
"Vector3.zero","Vector3.one","Vector3.up""Vector2.zero","Vector2.one","Vector2.right""Color.white","Color.red","Color.cyan""Quaternion.identity""Physics.DefaultRaycastLayers"
You can also use HTML color strings with Color and Color32 fields:
"#FF0000""#FF0000FF"
Comma-Separated Values
Some struct types can be created from comma-separated values:
Vector2:"1,2"Vector3:"1,2,3"Vector2Int:"1,2"Vector3Int:"1,2,3"Rect:"0,0,10,20"RectInt:"0,0,10,20"BoundsInt:"0,0,0,10,20,30"
This is useful when there is no simple named value for the default you want.
Examples
[DefaultValue(1f)]
public FloatVar speed;
[DefaultValue("Vector3.up")]
public Vector3Var direction;
[DefaultValue("Color.cyan")]
public ColorVar debugColor;
[DefaultValue("Z")]
public AxisDirectionVar facingAxis;
[DefaultValue("0,0,10,20")]
public RectVar viewport;
[DefaultValue("~MainCamera")]
public GameObjectVar cameraObject;
[DefaultValue(DefaultValueAttribute.None)]
public BoundsIntVar bounds;
OwnerDefaultValue
Specifies that the field's value should default to Owner.
Tip
There are some internal rules to identify Owner fields.
You only need to use the OwnerDefaultValue attribute if the field is not found automatically.
NotOwnerDefaultValue
Specifies that the field should NOT default to Owner.
Use this to override the internal rules if needed.
CanBeNullOrEmpty
Indicates that a required field is allowed to be null or empty.
For example, to indicate that a Unity Object field can be null, or a StringVar field can be empty.
VarRange
Similar to the Unity RangeAttribute but for FloatVar and IntegerVar fields.
| Parameter | Type | Description |
|---|---|---|
| min | float | The lower limit of the range. |
| max | float | The upper limit of the range. |
VarSlider
Displays a slider next to FloatVar or IntegerVar fields. The value field accepts values outside the slider range.
| Parameter | Type | Description |
|---|---|---|
| min | float | The lower limit of the range. |
| max | float | The upper limit of the range. |
ConvertibleName
Name that can be used to match fields in a ConvertibleGroup.
| Parameter | Type | Description |
|---|---|---|
| name | string | The name used to match fields in a convertible group. |
Fields in a convertible group are normally matched by name. Use this attribute if fields are convertible but have different names.
For example, ListGetNextItem and ListGetRandomItem have items fields with different names but are convertible.
DefaultName
Used when auto-adding a variable or event.
| Parameter | Type | Description |
|---|---|---|
| name | string | The default name used when auto-adding a variable or event. |
Normally the auto-created variable or event uses the field name. Use this attribute to define a custom name instead.
ActionTarget
Indicates that a field is the "target" for an action. For example, if placed on a GameObjectRef it indicates that the action targets GameObjects.
Action targets are used to populate drag and drop menus. For example, when dropping a GameObject into the action list, we look for all actions that target a GameObject.
Tip
There are some internal rules to identify target fields.
You only need to use the ActionTarget attribute if the field is not found automatically.
RequiredComponent
Specifies that the field requires a specific component.
| Parameter | Type | Description |
|---|---|---|
| componentType | Type | The required component. |
Tip
There are some internal rules to identify required components.
You only need to use the RequiredComponent attribute if the field is not found automatically.
ActionHeader
Show a header above a field in the action editor, similar to the Unity HeaderAttribute.
Use this to organize action fields into sections.
| Parameter | Type | Description |
|---|---|---|
| label | string | The header title. |
Note
Show a HelpBox above a field in the action editor.
Use this to add extra information that should be more prominent than a tooltip.
| Parameter | Type | Description |
|---|---|---|
| message | string | The message to show in the HelpBox. |
| messageType | HelpBox.messageType | What kind of HelpBox to show. |
DisplayOrder
Overrides the default order of the field in the UI.
By default, fields are shown in the order they are declared in. Sometimes you need to override this order. For example, when using a base class you often want the fields declared in the base class to appear before fields in the derived classes.
| Parameter | Type | Description |
|---|---|---|
| order | int | Smaller numbers are sorted first. For example: -1000 should guarantee that a field appears first. 1000 should guarantee that it appears at the end. |
HideDebugValue
Hide the debug value for this field.
LayerValue
Marks an IntegerVar as containing a Layer value, and shows the appropriate UI.
TagValue
Marks a StringVar as containing a Tag, and shows the appropriate UI.
Event Field Attributes
Attributes for EventRef fields.
GlobalEvent
Marks an event field as requiring a Global Event.
The event selector will only shows global events.
BroadcastEvent
Marks an event field as an event that will be broadcast.
You can only select global events for this field.
EventNotSent
Indicates that the event is not sent. This disables any "not used" errors on the field.
DisableEventNotUsedInTransitionsError
Disables the error check on an EventRef field.
Sometimes you want to use an EventRef field for an event that will not be sent.
MatchType
Makes sure the field matched the type of another field.
For example, in GetComponent, the StoreResult type needs to match the type of the selected ComponentType.
| Parameter | Type | Description |
|---|---|---|
| fieldName | string | Name of the action field to match. |
BaseType
Base type assignable to a variable field.
| Parameter | Type | Description |
|---|---|---|
| type | Type | The field can contain variables of this type or subclasses of this type. |
ArrayElementLabel
Use on a list field. Overrides the name of an element, normally Element 0, Element 1, etc.
| Parameter | Type | Description |
|---|---|---|
| name | string | The name to use as a label. |
ArrayElementTooltip
Use on a list field. Tooltip text to use on individual elements in the UI.
| Parameter | Type | Description |
|---|---|---|
| text | string | Text to use in the tooltip. |
HideArrayLabels
Used on a list field. Hides element labels in the UI.