Skip to content

Commit

Permalink
rename animation params to sorting order
Browse files Browse the repository at this point in the history
  • Loading branch information
lorux0 committed Oct 1, 2024
1 parent 1960784 commit 3cc081b
Showing 1 changed file with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,9 @@ private void CreateLayeredAnimatorController(IGltfImport gltfImport, string dire
string animationClipName = clip.name;

// Configure parameters
var triggerParameterName = $"{animationClipName}_Trigger";
var loopParameterName = $"{animationClipName}_{LOOP_PARAMETER}";
var enabledParameterName = $"{animationClipName}_Enabled";
var triggerParameterName = $"State_{i}_Trigger";
var loopParameterName = $"State_{i}_{LOOP_PARAMETER}";
var enabledParameterName = $"State_{i}_Enabled";

controller.AddParameter(triggerParameterName, AnimatorControllerParameterType.Trigger);

Expand All @@ -486,17 +486,19 @@ private void CreateLayeredAnimatorController(IGltfImport gltfImport, string dire
});

// Configure layers
string layerName = controller.MakeUniqueLayerName(animationClipName);
string layerName = controller.MakeUniqueLayerName($"State_{i}_Layer");
controller.AddLayer(new AnimatorControllerLayer
{
name = animationClipName,
name = layerName,
defaultWeight = isDefaultState ? 1f : 0f,
stateMachine = new AnimatorStateMachine(),
iKPass = false,
blendingMode = AnimatorLayerBlendingMode.Override,
avatarMask = null,
});
int layerIndex = GetLayerIndex();

// We have to add one since 0 is the base layer
int layerIndex = i + 1;
AnimatorControllerLayer layer = controller.layers[layerIndex];
AnimatorStateMachine layerStateMachine = layer.stateMachine;

Expand Down Expand Up @@ -539,17 +541,6 @@ private void CreateLayeredAnimatorController(IGltfImport gltfImport, string dire
toEmptyTransition.duration = 0;
toEmptyTransition.hasExitTime = true;
}

continue;

int GetLayerIndex()
{
for (var i = 0; i < controller.layers.Length; i++)
if (controller.layers[i].name == layerName)
return i;

return -1;
}
}

AssetDatabase.SaveAssets();
Expand Down

0 comments on commit 3cc081b

Please sign in to comment.