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

本文介绍了如何修改Unity3D的脚本模板,以添加详细的版权、描述和作者信息,从而加强项目管理和Bug责任追踪。通过在.EditorDataResourcesScriptTemplates路径下调整CS脚本模板,可以实现自定义的注释结构。
摘要由CSDN通过智能技术生成

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();
    }

   

   
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值