
很多时候 许多类 的 格式 都是重复的,比如 从配置文件中映射出来的类。
这个时候写一个 类模板 就很节省时间了。
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();
}