您的位置:首页 > 移动开发 > Unity3D

MMORPG手游制作-任务3.Unity项目结构和C#编辑模板

2018-01-26 17:14 351 查看
建立文件夹体系

Editor:工具

修改C#编辑的模板:

寻找到Unity下的文件:



结合Editor文件夹下编辑脚本对内容替换

using UnityEngine;

using System.Collections;

using System.IO;

using System;

using UnityEditor;

/// <summary>

/// 替换代码注释

/// </summary>

public class ScriptCreatInit : UnityEditor.AssetModificationProcessor 

{

    private static void OnWillCreateAsset(string path)

    {

        path = path.Replace(".meta","");

        if (path.EndsWith(".cs"))

        {

            string strContent = File.ReadAllText(path);

            strContent = strContent.Replace("#AuthorName#", "悠长de小巷")

                .Replace("#CreateTime#", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")

                );

            File.WriteAllText(path, strContent);

            AssetDatabase.Refresh();

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: