自定义修改Unity脚本模板

在Unity Editor中Create C# script后,会自动生成初始化脚本:

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 
 5 public class ScriptName : MonoBehaviour {
 6 
 7     // Use this for initialization
 8     void Start () {
 9         
10     }
11     
12     // Update is called once per frame
13     void Update () {
14         
15     }
16 }

这个是Unity默认脚本模板生成的,模板位于:
"C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates\81-C# Script-NewBehaviourScript.cs.txt"
可根据自己需要自定义自己想要的模板,如以下例子:

 1 /*
 2 * ==============================================================================
 3 *
 4 * Filename: $safeitemname$
 5 * Description: 
 6 *
 7 * Version: 1.0
 8 * Created: $time$
 9 * Compiler: Visual Studio 2017
10 *
11 * Author: Your name
12 * Company: Your company name
13 *
14 * ==============================================================================
15 */
16 
17 using System.Collections;
18 using System.Collections.Generic;
19 using UnityEngine;
20 
21 /// <summary>
22 ///
23 /// <summary>
24 public class #SCRIPTNAME# : MonoBehaviour {
25 
26     // Use this for initialization
27     void Start () {
28         #NOTRIM#
29     }
30     
31     // Update is called once per frame
32     void Update () {
33         #NOTRIM#
34     }
35 }

除此之外,C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates目录下还有其他类型的脚本模板,可根据需要进行修改!

posted on 2020-02-02 12:47  我来乔23  阅读(358)  评论(0编辑  收藏  举报

导航