- Home /
Unity 5.3 WebGL StateMachineBehaviours not executing.
I just updated to Unity 5.3, and decided to update one of the games on my website to the new WebGL build. When I tested the game, some of the functionality didn't execute. After a lot of debugging I narrowed it down to the functionality inside the StateMachineBehaviour scripts(its a 2D game).
for example: If I make a behaviour like this and attach it to an animation, then the object is destroyed while playing it as a standalone build or in the editor. But if I export it as a WebGL build the object isn't destroyed after the animation has finished playing.
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
Destroy(animator.gameObject);
}
Has anyone else experienced this, if so then I guess it needs to be reported as a bug.
EDIT: I have been in contact with the Unity bug report team, and I just recieved the following message:
Hey,
We have been able to reproduce this bug and have sent it for resolution with our developers.
We highly appreciate your contribution. If you have further questions, feel free to contact us.
Regards, Stefan
State$$anonymous$$achineBehaviors are broken for me in Unity 5.3 on iOS, maybe related. I get an error in XCode saying, for example, "OnStateEnter() cannot take parameters", but the build won't compile without the parameters in the override. I need to file a bug report, but I'm in crunch mode at the moment. Had to rip what little $$anonymous$$ecanim we had in our project out, because we can't revert to an earlier Unity version.
Can't say about WebGL but I do have the save problem as Bunderant : State$$anonymous$$achineBehaviour.OnStateEnter() is never called on iOS (though it works fine in editor and on Android). So I guess it does deserve a bug report. :)
I had the same issue on webgl, and after a lot of time debugging and narrowing down I reached this post. Any idea? I am running 5.3.0 but probably 5.3.1 will have the same behaviour since it was issued on Dec 18th, just 5 days after your question, and there is nothing related to state machine behaviours in the fixes list.
As a workaround, I got it working substituting the OnStateExit by an animation event in the last frame of the animation. Of course, this is not useful if the animation is a loop, but for me it worked. If you can see any regret in this workaround or can figure out any other approach, I'll be glad to listen.
Hi! After really long time debugging my stuff, I reached the same conclusion and ended up in this post. Any update? I am running 5.3.0f4 and the last version is 5.3.1, dec 18th, 5 days after your post and there is nothing on the fixes list related to this.
Did you find any workaround? I thought about adding an animation event in the animation itself ins$$anonymous$$d of a behaviour to the state, which sound weird but, at least in the editor, it works.
Any help welcome. efraim
Answer by Max Pushkarev · Jan 25, 2016 at 04:43 AM
Hi! I faced the same problem with StateMachineBehaviour in my project. I noticed that in WebGL you can avoid this bug by switching off "Code Stripping" option on PlayerSettings. This helped me.
Answer by Deepscorn · Jan 27, 2016 at 03:53 PM
I faced same bug but on IOs. I found several options, that can be used right now:
Disable "Code stripping" in player settings, as already proposed by Max Pushkarev
You can install patched Unity 5.3.1p3 or newer. Bad news - it is said, that patches don't work for WebGl
Downgrade. See bugs below. It is said that bug is not reproducable on some 5.2.x versions of Unity
Bugs:
https://issuetracker.unity3d.com/issues/webgl-statemachinebehaviours-not-executing https://issuetracker.unity3d.com/issues/stripping-statemachinebehaviour-overrides-not-called-on-ios
PS Bug will be fixed in Unity 5.4. But it's release date is march 16, 2016. So it is a long wait. I'm using 5.3.1p4 right now and for my IOS build all is good
Your answer