using UnityEngine;
using System.Collections;
using UnityEditor;
using System.Reflection;
public class ScriptObjectCreator : EditorWindow
{
public string scriptName;
public string fieldName;
public static void GetData()
{
string stringholderpath = "Assets/bonenames.asset";
TestScriptObject a = AssetDatabase.LoadAssetAtPath(stringholderpath, typeof(TestScriptObject)) as TestScriptObject;
Debug.LogError(a.test[0]);
}
[MenuItem("tools/CreateScriptObject")]
public static void GetWindow()
{
EditorWindow.GetWindow<ScriptObjectCreator>("CreatorWindow");
}
void OnGUI()
{
EditorGUILayout.BeginVertical();
scriptName = EditorGUILayout.TextField(scriptName, GUILayout.Width(250));
fieldName = EditorGUILayout.TextField(fieldName, GUILayout.Width(250));
if (GUILayout.Button(new GUIContent("确定")))
{
Assembly assembly = Assembly.GetExecutingAssembly();
System.Type[] types = assembly.GetTypes();
System.Type instanceType = null;
foreach (var a in types)
{
if(a.ToString() == scriptName)
{
instanceType = (System.Type)a;
break;
}
}
ScriptableObject temp = ScriptableObject.CreateInstance(instanceType);
string stringholderpath = "Assets/"+ fieldName + ".asset";
AssetDatabase.CreateAsset(temp, stringholderpath);
}
EditorGUILayout.EndVertical();
}
}
ScriptObject创建工具
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 引言 在开发中,对于json数据的处理总是很墨迹,而这也主要集中体现在模型的创建上,今天给大家推荐的一款工具就很完...
- 本文章来自【知识林】 摘要 对于Springboot的应用已有一段时间,发现在使用过程中每创建一个项目都依然还有很...