Wiki

Case Status
Log In

Wiki

 
Home ยป API Reference»Action Attributes
Index
Navigation
Community Wiki

Action Attributes

You can add Attributes to actions to customize their appearance in the Playmaker editor.

Attribute Description

ActionTarget

Defines an Object type that the Action works with.

Used by Playmaker to make relevant context menus, e.g., for drag and drop.

 

Parameters:

 

ObjectType: Defines the Object type that the Action works with.

FieldName: Defines the name of a field to set to the value of the target Object.

 

NOTES:

  • The ActionTarget system can convert between common Object targets. See ActionTargets.
  • You can define multiple ActionTargets on an Action.

 

C# Example:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
[ActionTarget(typeof(AudioSource), "gameObject")]                                  
[ActionTarget(typeof(AudioClip), "oneShotClip")]
public class AudioPlay : FsmStateAction
{
    public FsmOwnerDefault gameObject;		
    
    [ObjectType(typeof(AudioClip))]
    public FsmObject oneShotClip;

    ...
}

ActionCategory

Defines the action's category in the Action Browser.

 

Use either the built-in ActionCategory enum or a string value to define a custom category.

 

C# Example:

1:
2:
3:
4:
5:
[ActionCategory(ActionCategory.Animation)]                                         
public class MyAnimationAction : FsmStateAction

[ActionCategory("Custom")]
public class MyCustomAction : FsmStateAction

Tooltip

Defines rollover hints. Use on a class or any public field.

 

C# Example:

1:
2:
[Tooltip("This is the best action ever!")]                                         
public class MyCustomAction : FsmStateAction

HelpUrl

Defines a url to use for the help button next to the action title.

 

C# Example:

1:
2:
3:
[HelpUrl("http://hutonggames.com/playmakerforum/index.php?topic=1711.0")]          
public class ConvertSecondsToString : FsmStateAction
...

Note

Display a Note for extra information about the action.

 

C# Example:

1:
2:
3:
[Note("Warning, this action is super cool!")]                                      
public class MyAction : FsmStateAction
...

RequiredField

Use on any public field that the user must define. If the parameter is left undefined the editor will show an error.

 

C# Example:

1:
2:
[RequiredField]                                                                    
public FsmBool importantOption;

Title
Defines a new display name for an action field in the editor.
 
C# Example:
1:
2:
[Title("Position")]                                                                
public FsmRect screenRect;
CheckForComponent

Use on a public GameObject, FsmGameObject or FsmOwnerDefault field to check that the specified game object has the required components. Otherwise an error will show under the field.

 

NOTE, you can specify up to 3 component types to check for.

 

C# Example:

1:
2:
[CheckForComponent(typeof(Animation))]                                             
public FsmGameObject gameObjectToAnimate;

HasFloatSlider

Use on a public float field to show a slider.

 

NOTE, You specify min/max values for the slider, but you can still enter values outside that range in the edit field. This is by design...

 

C# Example:

1:
2:
[HasFloatSlider(0, 100)]                                                           
public FsmFloat health;

ArrayEditor

Use this attribute to show an appropriate editor for an FsmArray variable.

 

C# Example:

1:
2:
[ArrayEditor(VariableType.GameObject)]                                             
public FsmArray gameObjects;

 

Optional parameters let you customize the editor further:

 

public ArrayEditorAttribute(VariableType variableType, string elementName = "", int fixedSize = 0, int minSize = 0, int maxSize = 65536)

ActionSection

Use on a public field to create a bold section label above that field.

 

Use this to organize the UI.

 

UIHint

Use on a public field to help Playmaker show the most appropriate editor for the type of data.

 

See the table below for details.

 

ObjectType

Use on a public field to define FsmEnum and FsmObject types.

 

C# Example:

1:
2:
[ObjectType(typeof(LightType))]                                                    
public FsmEnum lightType;

 

C# Example:

1:
2:
[ObjectType(typeof(MonoBehaviour))]                                                
public FsmObject behaviour;

 

HideInInspector

NEW: 1.9.0

Use on a public field that you want to hide in the action editor.

HideIf

NEW: 1.9.0

Use on a public field, specifying a method name.

 

The method will be called by the editor to determine if the field should be shown or not. Return true to hide the field or false to show it.

 

SettingsMenuItem

NEW: 1.9.0

Use on a public static method to add a menu item to the action's Setttings Menu.

 

C# Example:

1:
2:
3:
4:
5:
6:
[SettingsMenuItem("Show Easing Preview")]                                          
public static void ToggleEasingPreview()
{
    showPreviewCurve = !showPreviewCurve;
    EditorPrefs.SetBool(showPreviewPrefsKey, showPreviewCurve);
}

SettingsMenuItemState

NEW: 1.9.0

Use on a public static method to return the checked state of a Settings Menu Item defined by SettingsMenuItem (above).

 

C# Example:

1:
2:
3:
4:
5:
[SettingsMenuItemState("Show Easing Preview")]                                     
public static bool GetPreviewState()
{
    return showPreviewCurve;
}

PreviewField

NEW: 1.9.0

Use on a public field to specify a method to draw a preview under the field in the editor.

 

C# Example:

1:
2:
3:
4:
[Tooltip("The type of easing to apply.")]                                          
[ObjectType(typeof(EasingFunction.Ease))]
[PreviewField("DrawPreview")]
public FsmEnum easeType;

DisplayOrder

NEW: 1.9.0

Use on a public field to change the display order of the parameter in the editor. 0 = first, 1 = second etc.

 

Useful when using inheritance in custom action editors. E.g., you specify some common parameters in a base editor class that you want to display at the top of the editor.

 

C# Example:

1:
2:
3:
4:
5:
[DisplayOrder(0)]
[RequiredField]
[Tooltip("The GameObject to tween.")]
[UIHint(UIHint.Variable)]
public FsmOwnerDefault gameObject;

NoErrorCheck

NEW: 1.9.5

Use on a public field to turn off error checking for that field.

 

For example, if an action defines events that aren't used in a transition you would normally get an "event not used" error. If you know that they are in fact used in some other way you can add this attribute to remove the error.

 

UIHint

Use a UIHint attribute on a public field to help Playmaker show the most appropriate editor for the type of data.

Hint Description
Animation Use on a string field to add an animation browser button. The browser will try to find animations on the targeted game object.
Behaviour  Use on a string field to add a Behavior popup button. The popup will attempt to find behaviors on the targeted game object.
Coroutine  Use on a string field to add a Coroutine popup button. The popup will attempt to find Coroutine methods on the targeted game object.
Description  Use on a string field to display the text in a large readonly info box.
Layer  Use on an integer field to show a Layer popup button.
Script  Use on a string field to add a script popup button. The popup will attempt to find scripts on the previously specified game object.
Tag  Use on a string field to show a Tag popup button.
TextArea Use on a string field to use a larger text edit field.
Variable  Use on an Fsm Variable field (FsmFloat, FsmInt, FsmBool...) to show a variable popup button used to select a variable of that type.
 

 


Last modified on 2/28/2023 8:22 AM by User.

  • RSS Feed