纳金网
标题:
Unity3d C#默认脚本模板修改
[打印本页]
作者:
烟雨
时间:
2016-3-7 22:05
标题:
Unity3d C#默认脚本模板修改
修改下面目录
Editor\Data\Resources\ScriptTemplates
的这个文件
81-C# Script-NewBehaviourScript.cs
修改文件内容如下:
/*
文件名(File Name): #SCRIPTNAME#.cs
作者(Author): #AuthorName#
创建时间(CreateTime): #CreateTime#
*/
using UnityEngine;
using System.Collections;
public class #SCRIPTNAME# : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
保存,修改完毕,然后在Assets目录下新建Editor文件夹,如果已经有就不用新建
新建脚本名字 ScriptTitleChange
将下面内容拷贝到脚本中,大功告成
using UnityEngine;
using System.Collections;
using System.IO;
public class ScriptTitleChange : UnityEditor.AssetModificationProcessor {
public static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta","");
if(path.EndsWith(".cs"))
{
string allText = File.ReadAllText(path);
allText = allText.Replace("#AuthorName#", "Jason").Replace("#CreateTime#",
System.DateTime.Now.Year+"-"+System.DateTime.Now.Month+"-"+System.DateTime.Now.Day+" "+
System.DateTime.Now.Hour+":"+System.DateTime.Now.Minute+":"+System.DateTime.Now.Second);
File.WriteAllText(path, allText);
}
}
}
复制代码
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5