mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 12:15:05 +08:00
Avoid copying animators that have nothing merged in
This commit is contained in:
parent
fb5f8c555e
commit
4ee54d47a1
@ -14,6 +14,9 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
|
||||
public int callbackOrder => HookSequence.SEQ_MERGE_ANIMATORS;
|
||||
|
||||
private Dictionary<VRCAvatarDescriptor.AnimLayerType, AnimatorController> defaultControllers_ =
|
||||
new Dictionary<VRCAvatarDescriptor.AnimLayerType, AnimatorController>();
|
||||
|
||||
Dictionary<VRCAvatarDescriptor.AnimLayerType, AnimatorCombiner> mergeSessions =
|
||||
new Dictionary<VRCAvatarDescriptor.AnimLayerType, AnimatorCombiner>();
|
||||
|
||||
@ -28,8 +31,16 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
|
||||
foreach (var merge in toMerge)
|
||||
{
|
||||
if (merge.animator != null && mergeSessions.TryGetValue(merge.layerType, out var session))
|
||||
if (merge.animator == null) continue;
|
||||
|
||||
if (!mergeSessions.TryGetValue(merge.layerType, out var session))
|
||||
{
|
||||
session = new AnimatorCombiner();
|
||||
mergeSessions[merge.layerType] = session;
|
||||
if (defaultControllers_.ContainsKey(merge.layerType))
|
||||
{
|
||||
session.AddController("", defaultControllers_[merge.layerType]);
|
||||
}
|
||||
var relativePath = RuntimeUtil.RelativePath(avatarGameObject, merge.gameObject);
|
||||
mergeSessions[merge.layerType].AddController(
|
||||
relativePath != "" ? relativePath + "/" : "",
|
||||
@ -57,9 +68,12 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
layers = (VRCAvatarDescriptor.CustomAnimLayer[]) layers.Clone();
|
||||
|
||||
for (int i = 0; i < layers.Length; i++)
|
||||
{
|
||||
if (mergeSessions.TryGetValue(layers[i].type, out var session))
|
||||
{
|
||||
layers[i].isDefault = false;
|
||||
layers[i].animatorController = mergeSessions[layers[i].type].Finish();
|
||||
layers[i].animatorController = session.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
return layers;
|
||||
@ -72,10 +86,7 @@ namespace net.fushizen.modular_avatar.core.editor
|
||||
var controller = ResolveLayerController(layer);
|
||||
if (controller == null) controller = new AnimatorController();
|
||||
|
||||
var session = new AnimatorCombiner();
|
||||
session.AddController("", controller);
|
||||
|
||||
mergeSessions[layer.type] = session;
|
||||
defaultControllers_[layer.type] = controller;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user