Problem is not reproducible or outdated
UI Image animation not working after update to 5.2.0
Hello everybody. I've been making a game in the older version(5.0.3 as far as I remember), and I've been using animations with UI Images. I have a portrait of a cat, I add it to image, then via the Animation tab I add the same image with its open mouth, then configurate animation controller in the Animator tab and it has been working perfect. But after the update every time I try to animate the image in the same way, when the cat is supposed to open his mouth he becomes a big white square and no animation plays. Besides, when I play the animation through the Animation tab, it works well with both in the scene and game tabs and I see it animating. But when I press "Play" button it doesn't. The UI image is a child of a standard Canvas with no properties changed. Who knows what's the problem and how to solve it?
And there is one more thing I forgot to add(I googled the problem but there were no answers) - besides the image animation broken, when it tries to animate there is always an error "Invalid AABB inAABB UnityEngine.Canvas:SendWillRenderCanvases()". I do not know what does this mean, but this error occurs only in this project - I tried to create an animation in the same way in another project, it did not work anyway but there was no such error.
Yep, there seems to be a bug with animation and updating the UI images. I use this temporary script to force the Image to update while the animation is playing (in Unity 4.6 though).
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
[RequireComponent(typeof(Animation))]
[RequireComponent(typeof(Image))]
public class UIAnimationUpdator : $$anonymous$$onoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (animation.isPlaying)
GetComponent<Image> ().SetAllDirty ();
}
}
Note you might prefer to have a reference of you Image in this script rather than doing a GetComponent() in the update as it is not very efficient.
this doesn't work - "There is no 'Animation' attached to the "Cat" game object, but a script is trying to access it." my image has Animator component, and even when I access it through GetComponent().GetBool("isTalking"), the SetAllDirty() method does not solve the problem. It is still a white square
ok your bug is not the same as $$anonymous$$e then :/ I don't have the solution atm
The AABB error was co$$anonymous$$g from a child animated image, it was not animated because of error in the parent image so do not $$anonymous$$d about that error. I also found out that even while the PLAY mode I can play the animation through the Animation tab and it will play as expected, but from the animator it does not...
Answer by Lazybones94 · Sep 25, 2015 at 01:45 PM
Solved - in the new version Unity does not allow animations with 0 speed
I'm experiencing what I believe to be a similar problem - when I add animations to UI images (in this case, changing the render color to cycle through a rainbow), the animation freezes on the first frame and refuses to advance past it. Like you said, it's viewable just fine through the Animator tab, but does not work in playmode.