using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using UnityEditor;
public class ScriptCreatInit : UnityEditor.AssetModificationProcessor {
private static string strContent = "//============================================\r\n"
+ "// 描述: \r\n"
+ "//作者:AuthoRName\r\n"
+ "//创建时间:CreateTime\r\n"
+ "//版本:v1.0\r\n"
+ "//==============================================\r\n";
private static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta", "");
if (path.EndsWith(".cs"))
{
strContent += File.ReadAllText(path);
strContent = strContent.Replace("AuthoRName", "RainSnow").Replace("CreateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
File.WriteAllText(path, strContent);
AssetDatabase.Refresh();
}
}
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System;
using UnityEditor;
public class ScriptCreatInit : UnityEditor.AssetModificationProcessor {
private static string strContent = "//============================================\r\n"
+ "// 描述: \r\n"
+ "//作者:AuthoRName\r\n"
+ "//创建时间:CreateTime\r\n"
+ "//版本:v1.0\r\n"
+ "//==============================================\r\n";
private static void OnWillCreateAsset(string path)
{
path = path.Replace(".meta", "");
if (path.EndsWith(".cs"))
{
strContent += File.ReadAllText(path);
strContent = strContent.Replace("AuthoRName", "RainSnow").Replace("CreateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
File.WriteAllText(path, strContent);
AssetDatabase.Refresh();
}
}
}
将此脚本放在Editor文件夹下即可