1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.Mod;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
@@ -22,23 +23,46 @@ namespace BITKit.Animations
|
||||
Singleton = this;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
ModService.OnReloaded += Rebuild;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
ModService.OnReloaded -= Rebuild;
|
||||
}
|
||||
|
||||
public bool TryMatch(out IMotionMatchingObject value, string[] key)
|
||||
{
|
||||
if (_objects.TryMatch(out value, key))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
BIT4Log.Log<ScriptableMotionMatchingService>($"找不到对应的MotionMatchingObject:{string.Join(",", key)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
var list = new List<ScriptableMotionMatchingObject>();
|
||||
var tags = new []{nameof(IMotionMatchingObject)};
|
||||
foreach (var x in YooAssets.GetAssetInfos(tags))
|
||||
{
|
||||
var assetHandle =YooAssets.LoadAssetSync<ScriptableMotionMatchingObject>(x.AssetPath);
|
||||
assetHandle.WaitForAsyncComplete();
|
||||
list.Add(assetHandle.AssetObject.As<ScriptableMotionMatchingObject>());
|
||||
var assetHandle =YooAssets.LoadAssetSync<ScriptableMotionMatchingObject>(x.AssetPath);
|
||||
assetHandle.WaitForAsyncComplete();
|
||||
list.Add(assetHandle.AssetObject.As<ScriptableMotionMatchingObject>());
|
||||
}
|
||||
_objects = new ObjectMatcher<string, IMotionMatchingObject>
|
||||
{
|
||||
list = list.ToArray(),
|
||||
};
|
||||
}
|
||||
|
||||
public bool TryMatch(out IMotionMatchingObject value, string[] key)=>_objects.TryMatch(out value,key);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user