UNITY EDITOR 创建脚本时增加备注:时间/作者/类名/描述

呃。。。最近永强整天在村头徘徊,看似漫无目的,其实他口袋里有一板砖,肯定不是锻炼身体。他希望能狭路相逢铁腕山。出其不意給老铁后脑勺一砖头。可惜啊,一个来月就这么过去了。铁腕山也没出现。

今天讲如何在创建脚本的时候給脚本增加一个备注开头

image

在Editor文件下创建一个脚本《ScriptTopComment》

using System.IO;
using System.Collections.Generic;
using UnityEngine;


namespace UGUIFrameWorkEditor
{
    public class ScriptTopComment : UnityEditor.AssetModificationProcessor
    {      
        public static void OnWillCreateAsset(string path)
{
            path = path.Replace(".meta", "");
            if (!path.EndsWith(".cs")) return;
            string scriptName = path.Substring(path.LastIndexOf('/')+1 );
            string allText = "/********************************************************************\r\n"
                            + " Copyright (C) 2017 IGG RD1 COG\r\n"
                            + " 类    名:#FILE_BASE#\r\n"
                            + " 创建时间:#CreateTime#\r\n"
                            + " 作    者:Birth.Fat \r\n"
                            + " 描    述:\r\n"
                            + " 版    本:1.0\r\n"
                            + "*********************************************************************/\r\n";
            allText += File.ReadAllText(path);
            allText = allText.Replace("#CreateTime#", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            allText = allText.Replace("#FILE_BASE#", scriptName);
            File.WriteAllText(path, allText);
        }
    }
}

好了 现在创建一个新Class试试吧,我现在创建一个新Class。

创建好后打开看一下,有没有惊喜!

/********************************************************************
 Copyright (C) 2017 IGG RD1 COG
 类    名:NewBehaviourScript.cs
 创建时间:2019-08-01 17:12:56
 作    者:Birth.Fat 
 描    述:
 版    本:1.0
*********************************************************************/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}

最近在研究Midi文件的解析,因为不懂音乐,所以研究的很想吐。研究Midi的目的是想做一个有关音乐类型的游戏。所以相关的技术先研究一下,如果你也有兴趣,请给我留言,任何想法都可以,核心玩法上,美术表现上,策划细节上都可以。期待你的留言。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容