Playmaker Forum

PlayMaker Help & Tips => PlayMaker Tips & Tricks => Topic started by: Thore on June 09, 2020, 10:55:05 AM

Title: Tip: Custom Action Template
Post by: Thore on June 09, 2020, 10:55:05 AM
I've come across this neat little trick. You know when you create a new script, you have it pre-filled with some standard Unity stuff (using statements, Enter and Update methods). You can customise it (Unity documentation (https://support.unity3d.com/hc/en-us/articles/210223733-How-to-customize-Unity-script-templates))

Where it's interesting for PlayMaker users: you can make a template for PlayMaker actions (and Scriptable Objects), too.

You have a few options. You can either do this for the entire Unity installation (see link above), or for a particular project, which I am going to show. You can replace the standard C# template with your own, but I am showing how to make a submenu that houses your own templates for some common script types. This keeps the standard as well.

/// HOW TO ///

In there, you need to place simple txt files with a certain file name. Inside the txt file, you define your template. There's only one parameter and that's #SCRIPTNAME# which will be substituted with the name you give when you make a new file. I have these three:

Code: [Select]
81-New Script__C# Script-NewBehaviourScript.cs
81-New Script__PlayMaker Action-NewPlayMakerAction.cs
81-New Script__Scriptable Object-NewScriptableObject.cs

81 is some Unity voodoo that determines where it's placed in the context menu. New Script is the menu name, then there are TWO underscores and then the name in the submenu to create from that template, and finally the default name of the newly created file.

I attach examples below, which you can customise (at least fill in author name, and namespace, or delete it, if you don't need it).

Oh, and to uninstall/remove this, just delete the file/folder again, and restart.
Title: Re: Tip: Custom Action Template
Post by: Rebooter on June 21, 2020, 11:30:27 PM
Thanks for this, very nice.
Title: Re: Tip: Custom Action Template
Post by: gamergirlpetra on January 10, 2021, 12:46:57 PM
Thank you, that was really helpful :)