Unity创建脚本Scripts头描述自定义

版权声明:转发,使用请留言告知 https://blog.csdn.net/qq_37310110/article/details/85630039

有两种方式,如果只是有个简单的toum头描述的就用方法一;如果想深度自定义就用方法二

方法一:

1;找到Unity的安装路径

2.打开81-C# Script-NewBehaviourScript.cs.txt文件并修改后保存就可以

这种方法只能加入固定的内容

方法二

1.同上 ,不同的是你可以自定义加入一些标签

2.在工程里的Editor路径下新建脚本做如下设置,如果有其他需求可以根据自己的需求gai

#region 模块信息
// **********************************************************************
// Copyright (C) 2019 The company name
//
// 文件名(File Name):             SpriteTitleChange.cs 
// 作者(Author):                  Circle
// 创建时间(CreateTime):           2017/1/7 15:34:45
// 修改者列表(modifier):
// 模块描述(Module description):   创建脚本自动修改文件名、作者、创建时间
// **********************************************************************
#endregion
using UnityEngine;
using System.Collections;
using System.IO;

public class SpriteTitleChange : UnityEditor.AssetModificationProcessor
{
    private static void OnWillCreateAsset(string path)
    {
        path = path.Replace(".meta", "");
        if (path.EndsWith(".cs"))
        {
            string allText = File.ReadAllText(path);
            allText = allText.Replace("#AuthorName#", "romantic123fly")
                              .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);
        }

    }
}

猜你喜欢

转载自blog.csdn.net/qq_37310110/article/details/85630039