示例#1
0
        public static Type Create <Type>(string path, bool createPath = true) where Type : ScriptableObject
        {
            if (path.IsNull())
            {
                return(default(Type));
            }
            var name    = path.GetPathTerm();
            var useName = typeof(Type).Name == "ScriptableObject";
            var folder  = Application.dataPath + Singleton.storagePath;

            path = folder.GetAssetPath() + path;
            if (createPath)
            {
                File.Create(folder);
            }
            ProxyEditor.ImportAsset(folder.GetAssetPath());
            try{
                ScriptableObject instance = useName ? ScriptableObject.CreateInstance(name) : ScriptableObject.CreateInstance <Type>();
                ProxyEditor.CreateAsset(instance, path);
                ProxyEditor.RefreshAssets();
                return(instance.As <Type>());
            }
            catch { Log.Warning("[Utility] No scriptableObject exists named -- " + name + ".asset"); }
            return(null);
        }