1、unity的脚本模板
新版本unity中的C#脚本有三类,第一类是我们平时开发用的C# Script;第二类是Testing,用来做单元测试;第三类是Playables,用作TimeLine中管理时间线上每一帧的动画、声音等。我们点击创建脚本时,会自动生成unity内置的一套模板:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
如果我们开发时使用的框架有明显的一套基础模板, 那为项目框架定制一套模板会很有意义,这样可以为我们省去编写重复代码的时间。这里介绍两种方法。
2、修改默认脚本模板
打开unity安装目录,比如D:unity2018EditorDataResourcesScriptTemplates,unity内置的模板脚本都在这里,那么可以直接修改这里的cs文件,比如我们将81-C# Script-NewBehaviourScript.cs.txt文件修改为如下,那下次创建C# Script时模板就会变成这样:
////////////////////////////////////////////////////////////////////
// _ooOoo_ //
// o8888888o //
// 88" . "88 //
// (| ^_^ |) //
// O = /O //
// ____/`---'____ //
// .' | |// `. //
// / ||| : |||// //
// / _||||| -:- |||||- //
// | | - /// | | //
// | _| ''---/'' | | //
// .-__ `-` ___/-. / //
// ___`. .' /--.-- `. . ___ //
// ."" '< `.____<|>_/___.' >'"". //
// | | : `- `.;` _ /`;.`/ - ` : | | //
// `-. _ __ /__ _/ .-` / / //
// ========`-.____`-.________/___.-`____.-'======== //
// `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //
////////////////////////////////////////////////////////////////////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class #SCRIPTNAME# : MonoBehaviour {
// Use this for initialization
void Start () {
#NOTRIM#
}
// Update is called once per frame
void Update () {
#NOTRIM#
}
}










