Strange bug with anchored position property in Animation

Hello, i found a strange bug (in Unity 5.1.1) when add anchored position property of RectTransform in My Animation.

  1. I use scripting to Moove Unity UI object to certain position;
  2. I need to use OnPointerEnter/Exit Animation when object on this position;
  3. When Animator disabled object mooves just as expected.
  4. When i enable Animator, object mooves only in scene view, and after that return to it’s start position, even if animation is not called. Is this a bug or i’m misunderstand something?
    Project with the problem attached. Load Bug scene, press a button and check unexpected behaviour of white square.

2189683–145245–Bug.unitypackage (15.5 KB)

Nobody knows? Does it mean, that i can’t use animator on UI object, and simultaneously move object by script? For example, if i have an animator with a couple of animation states, in a first state an object’s width is changing, a second state change object’s position. I need to move object by script and use a first animation while it’s moving, and after that, when object on a certain position, i need to use a second animation. Now it’s not possible, because when animator is enabled, even if no animation plays, object’s anchored position taken from a second animation start point, where anchored position property is set.
Sorry for my bad english, but did somebody understood me?

It’s a general issue that you can’t simply use script and animator for same purposes.
Some workaround is to create an empty state with no animation.
While in that state your object will follow the script.

The problem is that workaround is not working with ui objects. Even when animation is in default empty state, object still takes anchored position from other animation.

Another possibility is to deactivate the animator via AnimationEvent.
Try out if that works for you.

If i deactivate animator i’ll be unable to play any animations. But i need to control object width by first animation, and move object by script, and then move object by second animation.

have you tried to put the position calculating script on the animation itself via animationstatebehavior?
I would try that out myself but I am far away from home;)
Strange thing is, it worked fine with a new created cube, simple rotateing animation and moving script (while animator is in empty state) But as soon as I added some animations from another animator and reorganized the referenced objecrs, it screwed up everything. maybe it is only possible if you do it feom scratch

have you solved your problem? I found some hidden animator state with animations of the main object that blocked the script.
It worked perfectly again after deleating it.
But last thought, have you checked “Write defaults” in the animation state?
The last resort is to make a animator from scratch.

No, I have not solved this problem. I just made animation via script. And report a bug

The bug is still valid in 5.2.2, very very annoing

For the sake of completeness, you should look at this: