Unity3D 新建腳本自帶相應註釋,好做項目管理和Bug 責任追蹤

Unity 安裝目錄:.\Editor\Data\Resources\ScriptTemplates


如修改cs 腳本註釋:

原腳本樣板:

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#
 }
}

改成 :

/************************************************************************************
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;

public class #SCRIPTNAME# : MonoBehaviour {

 // Use this for initialization
 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();
    }

   

   
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章