您的位置:首页 > 移动开发 > Unity3D

Unity3D 新建脚本自带相应注释,好做项目管理和Bug 责任追踪

2017-08-07 23:04 369 查看
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();
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C# VR unity 注释 项目管理