Unity 安装目录:.\Editor\Data\Resources\ScriptTemplates
如修改cs 脚本注释:
原脚本样板:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
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#
}
}
void Start () {
#NOTRIM#
}
// Update is called once per frame
void Update () {
#NOTRIM#
}
}
改成 :
/************************************************************************************
Copyright : Copyright 2017 #SMARTDEVELOPERS#, LLC. All Rights reserved.
Description : #SCRIPTNAME#.#FILEEXTENSION#
ProductionDate : #CREATIONDATE#
Author : T-CODE
************************************************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
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#
}
}
void Start () {
#NOTRIM#
}
// Update is called once per frame
void Update () {
#NOTRIM#
}
}
保存-然后在项目编辑器中编辑Editor 脚本 新建脚本就自动有注释了:
/************************************************************************************ Copyright : Copyright 2017 XinYueVR, LLC. All Rights reserved. Description : HEScriptKeywordReplace.cs ProductionDate : 2017-02-06 19:01:00 Author : T-CODE ************************************************************************************/ using UnityEngine; using System.Collections; using UnityEditor; public class HEScriptKeywordReplace : UnityEditor.AssetModificationProcessor { public static void OnWillCreateAsset(string path) { path = path.Replace(".meta", ""); int index = path.LastIndexOf("."); string file = path.Substring(index); if (file != ".cs" && file != ".js" && file != ".boo") return; string fileExtension = file; index = Application.dataPath.LastIndexOf("Assets"); path = Application.dataPath.Substring(0, index) + path; file = System.IO.File.ReadAllText(path); file = file.Replace("#CREATIONDATE#", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); file = file.Replace("#PROJECTNAME#", PlayerSettings.productName); file = file.Replace("#SMARTDEVELOPERS#", PlayerSettings.companyName); file = file.Replace("#FILEEXTENSION#", fileExtension); System.IO.File.WriteAllText(path, file); AssetDatabase.Refresh(); } }