31 lines
877 B
C#
31 lines
877 B
C#
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
|
|
{
|
|
if (LoadAssetAsyncFactory is null)
|
|
{
|
|
throw new Exception("LoadAssetAsyncFactory is null!Make sure Processor has been initialized.");
|
|
}
|
|
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}");
|
|
}
|
|
}
|
|
}
|