Actions
A class is associated with each tool action. You can instantiate this class to run a process on a data stream.
Actions are the base foundation of the Toolbox and the Rule Engine. Each Action corresponds to an entry in the Toolbox and/or the Rule Engine.
Each action defines an input type and an output type:
Class | Description |
---|---|
ActionOut<OutputType> |
Use this class to create a start point, that is, to return results without input. |
ActionIn<InputType> |
Use this class to create an end point, that is, to prompt input without returning results. |
ActionInOut<InputType, OutputType> |
Use this class to create an action to prompt input, and then return results. This type of action is the most commonly used. |
The OutputType Run(InputType)
defines the Action execution steps.
Asset Transformer Toolkit Actions
Asset Transformer Actions inherit from PixyzAction
which itself inherit from ActionInOut<IList<GameObject>, IList<GameObject>>
. They are special actions for processing GameObjects directly inside Asset Transformer framework.
Any Asset Transformer API function, except IO
ones (forbidden by EULA), can be called from the OccurrenceList Run(OccurrenceList)
method. Input GameObjects are automatically converted to Asset Transformer occurrences before running this function, and input GameObjects are updated after.
Custom Actions
Asset Transformer provides a set of default Toolbox/Rule Engine Actions but you can create and define your own actions which will be available in the Asset Transformer Toolkit UI along the default ones. These actions are called Custom Actions.
Toolbox Actions must inherit from ActionInOut<IList<GameObject>, IList<GameObject>>
or PixyzAction
.
Input and output types must correspond in order to link actions in the Rule Engine. For example, an action inheriting from ActionOut<IList<GameObject>>
cannot be chained with an action inherting from ActionInOut<IList<Texture2D>, IList<GameObject>>
but can be chained with an action inheriting from ActionInOut<IList<GameObject>, IList<Texture2D>>
.
Note
Default Actions sources are available! Go check them in the com.unity.industry.toolkit/Editor/Actions
folder. It is very practical if you want to create a slight variation for an existing Action.
Create a Custom Action
To create a new custom action from a script template, right-click in your Assets and use one of these alternatives depending on whether you want to leverage Asset Transformer API or not:
- Create > Asset Transformer > C# Custom Action
- Create > Asset Transformer > C# Custom Asset Transformer Action
Warning
Script names must match class names.
Warning
Scripts must be placed in an Editor folder.
Add parameters
To add parameters, add fields and mark them with the UserParameter attribute.
A parameter can be of these types:
class
struct
list
enum
- A base type, such as
string
orint
For each parameter, the Toolbox or Rule Engine displays the proper input.
Add helper methods
Helper methods are parameterless methods that you can run through the Rule Engine.
To create a helper method, mark your method with the HelperMethod attribute.
To use helper methods, select the More button (…) in the Action section of the Rule Engine.
Display messages
You can display error messages, warning messages, and information messages.
You can override methods, such as the GetErrors()
method, for various purposes. For example, you might want to implement a parameter checking method to display an error message when a user enters an incorrect value.