Templates for creating custom actionsAs this seems to be the best place to share them and the Custom Action Wizard still creates pretty lagluster starting points, here are some templates (not to be confused with FSM-Templates) for writing custom actions, that contain pretty much everything you need to start off when creating a new custom action.
File-Description & -Links:- Template.cs - The minimum to create a new action
- TemplateAdvanced.cs - Derives from FsmStateActionAdvanced to automatically supply the option to choose an update type and adds the required comments that would be needed to share the action on the Ecosystem (you would still need access to the appropriate repository to commit the action to the Ecosystem)
- Editor\TemplateInspector.cs - If you want to change the look and functionality of an action, you can create a custom inspector with this (needs to be in a folder called "Editor" anywhere in your Assets folder, preferably near your base action)
Note: Remember that any Editor-Script cannot be executed in your build, so these are mainly for added functionality when the user sets up the action. That's why you also have to reference variables from the base script, because Unity only saves the values of those during runtime. - ExampleOverview.cs - A collection of further userful examples on things like compound arrays, enums and attributes to modify/style actions
Instructions: - Wherever you see the word "Template" in them, you should replace it with the name of your custom action.
- You should change the ActionCategory to something that fits your action type or give it an own name if none of the available ones are fitting.
- When creating a new variable, just copy over the tooltip and variable declaration of one that is already there and only copy the "[RequiredField]" attribute if that variable really needs to be set from the user of your action.
Previews:Even though the afore-mentioned wiki entry already contains a good overview on how to create certain custom action fields and its process, it doesn't provide a fast way of creating a new one like copying these templates over.
If you have suggestions on what should or shouldn't be in there, let me know.
Edit:|16.12.17|- Optimized TemplateInspector so that it only gets the reference to the action in OnEnable() instead of OnGUI() and added example on how to only draw single fields from the base script instead of drawing the whole inspector
- Added additional note to the TemplateInspector description
|23.12.17|- Added the ExampleOverview and moved a few lines from TemplateAdvanced to that
|31.12.17|- Added further OnPreprocess examples to ExampleOverview
- Removed the attachments, the in-line ExampleOverview-Preview and changed the script location from Gist to my main GitHub repository, so that I only have to update the scripts in one location when I change something
- reverted reference to action back to OnGUI() in TemplateInspector, because of a PlayMaker bug where it applied the cached action-reference to every open instance of that action, meaning that when the action was also selected in the Action Browser and I tried to get the action's owner, it constantly returned a Null-Reference-Exception because it also tried to get the owner of the action in the Asset Browser; also when two of the same actions where in one state and when changing values in one of them, it also applied them to the other instance (at least the values from the custom inspector) | having the action reference in OnGUI() works flawlessly now