This repository was archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
This repository was archived by the owner on May 19, 2023. It is now read-only.
Other playable layers than FX can accidentally be changed #7
Copy link
Copy link
Open
Description
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;
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels