Other playable layers than FX can accidentally be changed
Opened this issue · 1 comments
Ess-Ka commented
Ich suggest, to add an additinal validation for this:
public bool ValidateAnimatorController()
{
AnimatorController controller = GetAnimatorController();
if (controller == null)
return false;
_avaCryptController.ValidateAnimations(gameObject, controller);
_avaCryptController.ValidateParameters(controller);
_avaCryptController.ValidateLayers(controller);
return true;
}
private AnimatorController GetAnimatorController()
{
if (transform.parent != null)
{
EditorUtility.DisplayDialog("AvaCryptRoot component not on a Root GameObject.",
"The GameObject which the AvaCryptRoot component is placed on must not be the child of any other GameObject.",
"Ok");
return null;
}
Animator animator = GetComponent<Animator>();
if (animator == null)
{
EditorUtility.DisplayDialog("No Animator.",
"Add an animator to the Avatar's root GameObject.",
"Ok");
return null;
}
RuntimeAnimatorController runtimeController = animator.runtimeAnimatorController;
if (runtimeController == null)
{
EditorUtility.DisplayDialog("Animator has no AnimatorController.",
"Add an AnimatorController to the Animator component.",
"Ok");
return null;
}
AnimatorController controller = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEditor.Animations.AnimatorController>(UnityEditor.AssetDatabase.GetAssetPath(runtimeController));
if (controller == null)
{
EditorUtility.DisplayDialog("Could not get AnimatorController.",
"This shouldn't happen... don't know why this would happen.",
"Ok");
return null;
}
VRCAvatarDescriptor descriptor = GetComponent<VRCAvatarDescriptor>();
if (descriptor == null)
{
EditorUtility.DisplayDialog("Could not get AvatarDescriptor.",
"Add an AvatarDescriptor to the Avatar's root GameObject.",
"Ok");
return null;
}
else if (descriptor.baseAnimationLayers[4].animatorController == null)
{
EditorUtility.DisplayDialog("Could not get AvatarDescriptor.",
"Add an custom FX layer to your AvatarDescriptor.",
"Ok");
return null;
}
else if (descriptor.baseAnimationLayers[4].animatorController != runtimeController) {
EditorUtility.DisplayDialog("Current AnimatorController doesn't match.",
"Set the AnimatorController of the FX layer in your Animator component.",
"Ok");
return null;
}
return controller;
}
public void EncryptAvatar()
{
if (!ValidateAnimatorController())
return;
...
swiveI commented
maybe get the controller directly from the fx layer in the avatar descriptor. something like:
VRCAvatarDescriptor Avatar;
Avatar = GetComponent<VRCAvatarDescriptor>();
RuntimeAnimatorController FXAnimator;
FXAnimator = (RuntimeAnimatorController)Avatar.baseAnimationLayers[4].animatorController;