I am writing some code that synchronizes two animators, in a general way. The problem I am running into is that if a layer is synchronized, the unity kicks up a warning. 'Calling Animator.GotoState on Synchronize layer' Is there a way I can tell at run-time if an animator's layer is synchronized?
Is no one working on Mecanim anymore? This generates a bogus error that has no effect. Any further error that doesn't get logged is blamed on this message. Can we just shut it off?
I ran into the same thing in a system that tries to reset all layers to their default state. Ended up needing to make an array that the user has to use to manually specify which layers to reset, which is annoyingly pointless from the perspective of users. There are a lot of stupid things like this in Animator Controllers that either log an error without an exception the caller can catch or even worse, just silently fail to do what you want (like calling Play twice in the same frame simply ignores the second call). But yeah, probably no one's working on it because they're making a new animation system for DOTS. And given the general direction of DOTS ("performance by default" instead of "easy development by default") I fully expect them to come up with yet another poorly designed animation system.
For those who are looking for how to do this here is an editor only solution to get an array of layer sync flags: Code (CSharp): public bool[] GetSynchronizedLayerFlags(Animator animator) { var runtimeController = animator.runtimeAnimatorController; if(runtimeController == null) { Debug.LogErrorFormat("RuntimeAnimatorController must not be null."); return; } if (runtimeController is AnimatorOverrideController overrideController) { runtimeController = overrideController.runtimeAnimatorController; } var controller = runtimeController as UnityEditor.Animations.AnimatorController; if(controller == null) { Debug.LogErrorFormat("AnimatorController must not be null."); return; } var synchronizedLayers = new bool[controller.layers.Length]; for (var index = 0; index < controller.layers.Length; index++) { synchronizedLayers[index] = (uint) controller.layers[index].syncedLayerIndex < (uint) controller.layers.Length; } return synchronizedLayers; } This code is based off of posts Getting AnimatorController from Animator and Getting AnimatorController from Animator