using UnityEngine;
using UnityEditor;
using System.IO;
public class CustomAssets<T> : ScriptableObject
{
static string configPath = string.Format("Assets/Main/{0}.asset", typeof(T).ToString());
public T m_list;
[MenuItem("ArgsList/CreateArgsList")]
static void CreateArgsList()
{
if (!File.Exists(configPath))
CreateAsset();
}
public static void CreateAsset()
{
//将对象实例化
ScriptableObject so = ScriptableObject.CreateInstance(typeof(global::T));
if (so == null)
{
Debug.Log("该对象无效,无法将对象实例化");
return;
}
string path = Application.dataPath + "/Main";
//判断该路径是否存在,不存在的话创建一个
if (Directory.Exists(path) == false)
{
Directory.CreateDirectory(path);
}
AssetDatabase.CreateAsset(so, configPath);
}
}
该脚本放在Editor下面