mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 12:15:05 +08:00
feat: detect blendtree parameters in MA Parameters UI (#614)
This commit is contained in:
parent
1d6a1634db
commit
66d3eee78d
@ -137,6 +137,12 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
WalkAnimator(parameters, merger.animator as AnimatorController);
|
WalkAnimator(parameters, merger.animator as AnimatorController);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ModularAvatarMergeBlendTree mergeBlendTree:
|
||||||
|
{
|
||||||
|
WalkBlendTree(parameters, mergeBlendTree.BlendTree as BlendTree);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +247,8 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
|
|
||||||
foreach (var state in sm.states)
|
foreach (var state in sm.states)
|
||||||
{
|
{
|
||||||
|
WalkBlendTree(parameters, state.state.motion as BlendTree);
|
||||||
|
|
||||||
foreach (var behavior in state.state.behaviours)
|
foreach (var behavior in state.state.behaviours)
|
||||||
{
|
{
|
||||||
if (behavior is VRCAvatarParameterDriver driver)
|
if (behavior is VRCAvatarParameterDriver driver)
|
||||||
@ -269,6 +277,51 @@ namespace nadena.dev.modular_avatar.core.editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void WalkBlendTree(
|
||||||
|
Dictionary<string, DetectedParameter> parameters,
|
||||||
|
BlendTree blendTree,
|
||||||
|
HashSet<Motion> visited = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (blendTree == null) return;
|
||||||
|
if (visited == null) visited = new HashSet<Motion>();
|
||||||
|
if (visited.Contains(blendTree)) return;
|
||||||
|
|
||||||
|
visited.Add(blendTree);
|
||||||
|
|
||||||
|
if (blendTree.blendType != BlendTreeType.Direct)
|
||||||
|
{
|
||||||
|
Register(blendTree.blendParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blendTree.blendType != BlendTreeType.Direct && blendTree.blendType != BlendTreeType.Simple1D)
|
||||||
|
{
|
||||||
|
Register(blendTree.blendParameterY);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var child in blendTree.children)
|
||||||
|
{
|
||||||
|
if (blendTree.blendType == BlendTreeType.Direct)
|
||||||
|
{
|
||||||
|
Register(child.directBlendParameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
WalkBlendTree(parameters, child.motion as BlendTree);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Register(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name)) return;
|
||||||
|
if (parameters.ContainsKey(name)) return;
|
||||||
|
|
||||||
|
parameters.Add(name, new DetectedParameter()
|
||||||
|
{
|
||||||
|
IsPrefix = false,
|
||||||
|
OriginalName = name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void ApplyRemappings(ref Dictionary<string, DetectedParameter> parameters,
|
private static void ApplyRemappings(ref Dictionary<string, DetectedParameter> parameters,
|
||||||
ModularAvatarParameters parametersComponent)
|
ModularAvatarParameters parametersComponent)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user