Can I customize the addcomponent menu??

Hi all
I’d like to have my own addcomponent menu which make new script whose class derived from a specific class.
For example…

:slight_smile:
public abstract class Base : MonoBehaviour
{
}

public class NewScript : Base { void Start() {} .... }

And the menu looks like this.
1752486--110836--upload_2014-8-28_18-35-29.png

1752486--110837--upload_2014-8-28_18-35-55.png

Need new class name but only for c# script…
Can I make menu like this???
Can anybody help me?? Please~!!

You can change the script template and use the default Add Component menu:

using UnityEngine;
using System.Collections;

public class #SCRIPTNAME# : MyBaseClass {

    // Use this for initialization
    void Start () {
 
    }
 
    // Update is called once per frame
    void Update () {
 
    }
}

The templates are located in:

  • Windows: \Program Files\Unity\Editor\Data\Resources\ScriptTemplates
  • MAC: /Applications/Unity/Unity.app/Contents/Resources/ScriptTemplates

Changing the script templates only gets you so far… specifically, it only gets you until you update to the next version.

Besides that, there are half a dozen different ways I could use scripts, why should I be limited to just one template?

To solve the first problem you could have a copy of the template in your project and create a menu option that replaces the template with your copy.

To solve the second problem you need create a custom editor window but to be honest I don’t see the point for what the OP wants. How long does it take you to change the base class of a script? 5 seconds? You have to open the script anyway to write your code.

Thank you guys for many answers.
Looks, It’s not possible to have my own extra script template, except making some other stuff to make new script…