您的位置:首页 > 其它

Create Script Template In Edit Mode

2015-05-19 10:31 375 查看
很多时候 许多类 的 格式 都是重复的,比如 从配置文件中映射出来的类。

这个时候写一个 类模板 就很节省时间了。

Code

public static string TestPath = "Assets/Test.cs";
public static string TestValue = "\"test\"";
public static string TestCode =
@"
using UnityEngine;
using System;
using System.Text;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using com.kuxiong.battlemodule;
using System.Linq;

namespace com.kuxiong.battlemodule
{
public class Test
{
public string name = " + TestValue + @";
}
}";

[MenuItem("MyTest/Test")]
public static void Test()
{
Debug.Log("Creating Test Vo");

System.IO.File.WriteAllText(TestPath, TestCode);

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