1
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "BITKit.MotionMatching",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:e34a5702dd353724aa315fb8011f08c3",
|
||||
"GUID:296866320aab85a42a0403bf684bac59"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e9ced9430d8ee743b37f99f97066130
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Src/Unity/Scripts/MotionMatching/IMotionMatchingService.cs
Normal file
50
Src/Unity/Scripts/MotionMatching/IMotionMatchingService.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Animations
|
||||
{
|
||||
public interface IMotionMatchingObject
|
||||
{
|
||||
|
||||
}
|
||||
public interface IMotionMatchingService : IObjectMatcher<string,IMotionMatchingObject>
|
||||
{
|
||||
|
||||
}
|
||||
public interface IMotionMatchingClip
|
||||
{
|
||||
public AnimationClip Clip { get; }
|
||||
}
|
||||
public interface IMotionMatchingDualClip
|
||||
{
|
||||
public AnimationClip Clip1 { get; }
|
||||
public AnimationClip Clip2 { get; }
|
||||
}
|
||||
|
||||
public interface IMotionMatchingSequence
|
||||
{
|
||||
public AnimationClip[] Sequence { get; }
|
||||
}
|
||||
[Serializable]
|
||||
public struct MotionMatchingClip:IMotionMatchingObject,IMotionMatchingClip
|
||||
{
|
||||
[SerializeField] private AnimationClip clip;
|
||||
public AnimationClip Clip => clip;
|
||||
}
|
||||
[Serializable]
|
||||
public struct MotionMatchingSequence:IMotionMatchingObject,IMotionMatchingSequence
|
||||
{
|
||||
[SerializeField] private AnimationClip[] sequence;
|
||||
public AnimationClip[] Sequence => sequence;
|
||||
}
|
||||
[Serializable]
|
||||
public struct MotionMatchingDualClip:IMotionMatchingObject,IMotionMatchingDualClip
|
||||
{
|
||||
[SerializeField] private AnimationClip clip1;
|
||||
[SerializeField] private AnimationClip clip2;
|
||||
public AnimationClip Clip1 => clip1;
|
||||
public AnimationClip Clip2 => clip2;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69eecdba9d378da4eb5f5d18ab46d395
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit.Animations
|
||||
{
|
||||
public class ScriptableMotionMatchingObject : ScriptableObject,IObjectElement<string,IMotionMatchingObject>
|
||||
{
|
||||
[SerializeReference,SubclassSelector] private IReference[] tags;
|
||||
[SerializeReference,SubclassSelector] private IMotionMatchingObject value;
|
||||
public bool IsMatch(string[] searchKey)=>MathE.Contains(tags.Cast(),searchKey);
|
||||
public IMotionMatchingObject GetValue() => value;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b43979511dcafe047b047852cf9f3c47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.Mod;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
namespace BITKit.Animations
|
||||
{
|
||||
[Serializable]
|
||||
public struct ScriptableMotionMatchingSingleton:IMotionMatchingService
|
||||
{
|
||||
public bool TryMatch(out IMotionMatchingObject value, string[] key)=>ScriptableMotionMatchingService.Singleton.TryMatch(out value,key);
|
||||
}
|
||||
public class ScriptableMotionMatchingService : MonoBehaviour,IMotionMatchingService
|
||||
{
|
||||
internal static ScriptableMotionMatchingService Singleton { get; private set; }
|
||||
|
||||
private ObjectMatcher<string,IMotionMatchingObject> _objects;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
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>());
|
||||
}
|
||||
_objects = new ObjectMatcher<string, IMotionMatchingObject>
|
||||
{
|
||||
list = list.ToArray(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bb2b7abd7225af4eb99da89cc0f234e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
11
Src/Unity/Scripts/MotionMatching/UnityMotionMatching.cs.meta
Normal file
11
Src/Unity/Scripts/MotionMatching/UnityMotionMatching.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d35c39411ad5a6f4cafc63c5b93d9ce1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user