Bug with the Write Defaults?


I recently upgrade my project to unity 5, and I was hoping that the ‘Write Defaults’ property on an animation state would help me.

But it seems bugged, or it does not work like I was expecting it.

Let me explain my problem:

I have a component that is initaly disabled on my object (let’s say BoxCollider2D)

During an animation state (Attack), I enable BoxCollider2D, and at the end of this animation state, I disable it (so his initial value).

But if I interrupt my Attack to go back to my Idle animation state (via a trigger for example), the BoxCollider2D will not return to ‘disabled’.

No matter if I check or not ‘Write Defaults’ on my Idle animation state.

Am I missing something? Isn’t it supposed to reset values of animated properties?

If not, do you know a way to do what I want to do? Without resetting manually all the properties into the ‘Idle’ state?

While I was preparing a project to reproduce the bug, I found that the problem wasnt really what I described before.

Just before I reset my animation, I deactivate / activate my gameobject to force the OnDisable() of all component to be executed. I guess it’s not a good idea, that is what provoked the bug.

// This will reset all components
gameObject.SetActive (false);
gameObject.SetActive (true);


So I close this question