1
This commit is contained in:
26
Src/Core/Mod/ModService_IO.cs
Normal file
26
Src/Core/Mod/ModService_IO.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace BITKit.Mod
|
||||
{
|
||||
public partial class ModService
|
||||
{
|
||||
public static Func<string, UniTask<object>> LoadAssetAsyncFactory;
|
||||
|
||||
public static async UniTask<T> LoadAsset<T>(string location) where T : class
|
||||
{
|
||||
foreach (var func in LoadAssetAsyncFactory.CastAsFunc())
|
||||
{
|
||||
var value = await func.Invoke(location);
|
||||
if (value is T value1)
|
||||
{
|
||||
return value1;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception($"Asset not found: {location}");
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user