mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
TEngine全面更新,升级YooAsset2.1.1、UniTask、UIWindow、I2Localization
This commit is contained in:
@@ -5,41 +5,41 @@ using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class SettingLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载相关的配置文件
|
||||
/// </summary>
|
||||
public static TSetting LoadSettingData<TSetting>() where TSetting : ScriptableObject
|
||||
{
|
||||
var settingType = typeof(TSetting);
|
||||
var guids = AssetDatabase.FindAssets($"t:{settingType.Name}");
|
||||
if (guids.Length == 0)
|
||||
{
|
||||
Debug.LogWarning($"Create new {settingType.Name}.asset");
|
||||
var setting = ScriptableObject.CreateInstance<TSetting>();
|
||||
string filePath = $"Assets/{settingType.Name}.asset";
|
||||
AssetDatabase.CreateAsset(setting, filePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
return setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (guids.Length != 1)
|
||||
{
|
||||
foreach (var guid in guids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
Debug.LogWarning($"Found multiple file : {path}");
|
||||
}
|
||||
throw new System.Exception($"Found multiple {settingType.Name} files !");
|
||||
}
|
||||
public class SettingLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载相关的配置文件
|
||||
/// </summary>
|
||||
public static TSetting LoadSettingData<TSetting>() where TSetting : ScriptableObject
|
||||
{
|
||||
var settingType = typeof(TSetting);
|
||||
var guids = AssetDatabase.FindAssets($"t:{settingType.Name}");
|
||||
if (guids.Length == 0)
|
||||
{
|
||||
Debug.LogWarning($"Create new {settingType.Name}.asset");
|
||||
var setting = ScriptableObject.CreateInstance<TSetting>();
|
||||
string filePath = $"Assets/{settingType.Name}.asset";
|
||||
AssetDatabase.CreateAsset(setting, filePath);
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
return setting;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (guids.Length != 1)
|
||||
{
|
||||
foreach (var guid in guids)
|
||||
{
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
Debug.LogWarning($"Found multiple file : {path}");
|
||||
}
|
||||
throw new System.Exception($"Found multiple {settingType.Name} files !");
|
||||
}
|
||||
|
||||
string filePath = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
var setting = AssetDatabase.LoadAssetAtPath<TSetting>(filePath);
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
}
|
||||
string filePath = AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
var setting = AssetDatabase.LoadAssetAtPath<TSetting>(filePath);
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user