在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目录下还有其他类型的脚本模板,可根据需要进行修改!

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2021-12-12
  • 2021-12-03
  • 2021-07-01
  • 2021-07-29
  • 2021-06-08
  • 2021-11-09
猜你喜欢
  • 2021-08-25
  • 2021-10-25
  • 2022-12-23
  • 2021-12-03
  • 2021-06-14
相关资源
相似解决方案