码迷,mamicode.com
首页 > 其他好文 > 详细

Create Script Template In Edit Mode

时间:2015-05-19 12:40:20      阅读:120      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!