- 最后登录
- 2021-7-6
- 注册时间
- 2012-12-27
- 阅读权限
- 90
- 积分
- 76145
- 纳金币
- 53488
- 精华
- 316
|
修改下面目录
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);
- }
-
- }
- }
复制代码 |
|