首页 > 其他 > 详细

Create Script Template In Edit Mode

时间:2015-05-19 12:37:33      阅读:257      评论:0      收藏:0      [点我收藏+]

很多时候 许多类 的 格式 都是重复的,比如 从配置文件中映射出来的类。

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

 

Code

 1     public static string TestPath = "Assets/Test.cs";
 2     public static string TestValue = "\"test\"";
 3     public static string TestCode =
 4 @"
 5 using UnityEngine;
 6 using System;
 7 using System.Text;
 8 using System.Reflection;
 9 using System.Collections;
10 using System.Collections.Generic;
11 using com.kuxiong.battlemodule;
12 using System.Linq;
13 
14 namespace com.kuxiong.battlemodule
15 {
16     public class Test
17     {
18         public string name = " + TestValue + @";
19     }
20 }";
21 
22 
23     [MenuItem("MyTest/Test")]
24     public static void Test()
25     {
26         Debug.Log("Creating Test Vo");
27 
28         System.IO.File.WriteAllText(TestPath, TestCode);
29 
30         AssetDatabase.ImportAsset(TestPath);
31         AssetDatabase.Refresh();
32     }

Create Script Template In Edit Mode

原文:http://www.cnblogs.com/chongxin/p/4513866.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!