mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-02-06 22:02:48 +08:00
Fix up animator layer control references within the same animator
This change adjusts the layer indices for animator layer control state behaviors, assuming that the reference is for a layer in the same animator. This partially addresses #67 for v1.0; fully addressing this requires figuring out how to specify a reference to an arbitrary other Merge Animator target.
This commit is contained in:
parent
bd9e3711ea
commit
4be0293d9d
@ -28,6 +28,7 @@ using System.Linq;
|
|||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.Animations;
|
using UnityEditor.Animations;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using VRC.SDK3.Avatars.Components;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace net.fushizen.modular_avatar.core.editor
|
namespace net.fushizen.modular_avatar.core.editor
|
||||||
@ -47,6 +48,8 @@ namespace net.fushizen.modular_avatar.core.editor
|
|||||||
private Dictionary<KeyValuePair<String, AnimatorStateMachine>, AnimatorStateMachine> _stateMachines =
|
private Dictionary<KeyValuePair<String, AnimatorStateMachine>, AnimatorStateMachine> _stateMachines =
|
||||||
new Dictionary<KeyValuePair<string, AnimatorStateMachine>, AnimatorStateMachine>();
|
new Dictionary<KeyValuePair<string, AnimatorStateMachine>, AnimatorStateMachine>();
|
||||||
|
|
||||||
|
private int controllerBaseLayer = 0;
|
||||||
|
|
||||||
public AnimatorCombiner()
|
public AnimatorCombiner()
|
||||||
{
|
{
|
||||||
_combined = Util.CreateAnimator();
|
_combined = Util.CreateAnimator();
|
||||||
@ -61,6 +64,8 @@ namespace net.fushizen.modular_avatar.core.editor
|
|||||||
|
|
||||||
public void AddController(string basePath, AnimatorController controller, bool? writeDefaults)
|
public void AddController(string basePath, AnimatorController controller, bool? writeDefaults)
|
||||||
{
|
{
|
||||||
|
controllerBaseLayer = _layers.Count;
|
||||||
|
|
||||||
foreach (var param in controller.parameters)
|
foreach (var param in controller.parameters)
|
||||||
{
|
{
|
||||||
if (_parameters.TryGetValue(param.name, out var acp))
|
if (_parameters.TryGetValue(param.name, out var acp))
|
||||||
@ -136,6 +141,23 @@ namespace net.fushizen.modular_avatar.core.editor
|
|||||||
|
|
||||||
asm = deepClone(layerStateMachine, (obj) => customClone(obj, basePath));
|
asm = deepClone(layerStateMachine, (obj) => customClone(obj, basePath));
|
||||||
|
|
||||||
|
foreach (var state in asm.states)
|
||||||
|
{
|
||||||
|
foreach (var behavior in state.state.behaviours)
|
||||||
|
{
|
||||||
|
switch (behavior)
|
||||||
|
{
|
||||||
|
case VRCAnimatorLayerControl layerControl:
|
||||||
|
{
|
||||||
|
// TODO - need to figure out how to handle cross-layer references. For now this will handle
|
||||||
|
// intra-animator cases.
|
||||||
|
layerControl.layer += controllerBaseLayer;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_stateMachines[cacheKey] = asm;
|
_stateMachines[cacheKey] = asm;
|
||||||
return asm;
|
return asm;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user