I have created a project to reproduce the problem I'm currently facing. I'm running a simple unity animation that moves a game object and expect to be able to reset the gameobject position. This can be done by adding an empty animation, that (since it does not change anything) simply writes the default values, thus returning our gameobject to its original position.
But here is where things get complicated: if the animator gameobject is set inactive while the animation is running, new incorrect defaults values will be saved when gameobject is activated, and I am unable to reset my gameobject position.
To reproduce this issue, run the attached project: (Download from here)
- Change the stop method to "PlayEmpty"
- Hit Start Animation and watch the left "Hello world" text travel.
- While it is traveling, click Disable Text GO. The left text disappears.
- Click Enable Text GO and see the text comes back at its last location.
- Click Start Animation and watch the left "Hello world" text travel.
- Click Stop Animation - the text is returned to the position where it was when enabling the gameobject, rather than its original position.
Any help is welcome, suggestions on how to change the code to make the above scenario work.