Unable to make animations for UI Image
I'm trying to create an animation that rotates an UI image. I've done that in that sam eproject, so it should be possible. But whenever I change the rotation value at any frame, it resets.
According to the curves, it's actually taking the values correctly to create the curve, but for some reason it resets on the Dopesheet, and on play the animation is not played
This seems to affect only rotation, other properties can be modified. And is not just in one Image, is in every new Image I try to animate
I can't tell if I'm doing something wrong or my project just get corrupted. An yone knows what's goign on here?
I've tried again, now it gives me this error:
NullReferenceException UnityEditorInternal.CurveBindingUtility.SampleAnimationClip (UnityEngine.AnimationClip clip, Single time) (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/CurveBindingUtility.cs:66) UnityEditorInternal.CurveBindingUtility.SampleAnimationClip (UnityEngine.GameObject rootGameObject, UnityEngine.AnimationClip clip, Single time) (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/CurveBindingUtility.cs:39) UnityEditorInternal.AnimationWindowState.ResampleAnimation () (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/AnimationWindowState.cs:779) UnityEditorInternal.AnimationWindowState.set_currentTime (Single value) (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/AnimationWindowState.cs:1215) UnityEditor.AnimEditor.PlaybackUpdate () (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/AnimEditor.cs:231) UnityEditor.AnimEditor.Update () (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/AnimEditor.cs:166) UnityEditor.AnimationWindow.Update () (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/Animation/AnimationWindow/AnimationWindow.cs:42) System.Reflection.$$anonymous$$ono$$anonymous$$ethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/$$anonymous$$ono$$anonymous$$ethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.$$anonymous$$ono$$anonymous$$ethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/$$anonymous$$ono$$anonymous$$ethod.cs:232) System.Reflection.$$anonymous$$ethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/$$anonymous$$ethodBase.cs:115) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/HostView.cs:187) UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/HostView.cs:180) UnityEditor.HostView.SendUpdate () (at C:/buildslave/unity/build/Editor/$$anonymous$$ono/HostView.cs:245) UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorApplicationBindings.gen.cs:217)
Im using the 5.3.1f1 and have the same problem. Even in script does not rotate at all.
Edit: I mean only with script i can spin a UI Image
Answer by lassade · Feb 16, 2016 at 10:21 PM
I tried with a a clean scene and also have this problem, so my suggestion is:
Update Unity to the most recent version, (if is too much work try search in the change log for this bug fix frist)
Build a script to do the rotation: (Hack)
If is a simple rotation do Like this:
public class Rotate360 : MonoBehaviour {
public float speed;
// Update is called once per frame
void Update () {
transform.rotation = transform.rotation * Quaternion.Euler(0, 0, speed * Time.deltaTime);
}
}
For more complex stuff use this script and simple animate the rotation field (Not Tested)
[ExecuteInEditMode]
public class ApplyRotation : MonoBehaviour {
public Vector3 rotation;
public Transform t;
// Use this for initialization
void Start () {
t = transform;
}
// Update is called once per frame
void Update () {
t.rotation = Quaternion.Euler(rotation);
}
}
Your answer
Follow this Question
Related Questions
How to match position with Mini Map UI 0 Answers
How to have get button display a raw image? 3 Answers
How to move a UI Image in the z axis? 2D 0 Answers
Hotbar appears when a certain gameobject is selected? 1 Answer
How to make an object the root of a prefab, or remove the canvas that is set as the root of a prefab 0 Answers