我的Unity(20)

编辑器模式下 新的资源都是唯一的GUID 调用的方法

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

public class ScriptsCreateInit : UnityEditor.AssetModificationProcessor {

    private static void OnWillCreateAsset(string path)
    {
        Debug.Log(path);
        path = path.Replace(".meta","");
        if (path.EndsWith(".cs"))
        {
            Debug.Log("true");
            string strContent = File.ReadAllText(path);

            strContent = strContent.Replace("#AuthorName#", "XXX").Replace("#CreateTime#", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
          
            File.WriteAllText(path,strContent);
            AssetDatabase.Refresh();

        }
    }
}

在这里插入图片描述

是因为你的xml 表的保存格式不是utf-8的重新保存一下

猜你喜欢

转载自blog.csdn.net/m_cainiaokuaifei/article/details/95304324