- Home /
How can use Animation.Clip on scriptable object?
I have a a scriptable object with a Image attached to it and I'm trying to animate that Image using Animation.Clip can't succeed whatever I try.
There are two error codes
'Portrait Right(which contains my image)' AnimationEvent has no function name specified!
and
The variable anim of SpeakerUI has not been assigned. You probably need to assign the anim variable of the SpeakerUI script in the inspector.
Here are the scripts I use:
[CreateAssetMenu(fileName = "New Character", menuName = "Character")] public class Character : ScriptableObject { public string fullName; public Sprite portrait; public AnimationClip anim; }
and
ing System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro;
public class SpeakerUI : MonoBehaviour
{ public Image portrait; public TextMeshProUGUI fullName; public TextMeshProUGUI convo; public Animator anim;
private Character speaker;
public Character Speaker
{
get { return speaker; }
set
{
speaker = value;
portrait.sprite = speaker.portrait;
anim.enabled = true;
fullName.text = speaker.fullName;
}
}
public string Dialog
{
set { convo.text = value; }
}
public bool HasSpeaker()
{
return speaker != null;
}
public bool SpeakerIs(Character character)
{
return speaker == character;
}
public void Show()
{
gameObject.SetActive(true);
}
public void Hide()
{
gameObject.SetActive(false);
}
}
Can someone help me out animating the image?
Your answer
Follow this Question
Related Questions
How can i check if animation has finished playing if the object have no animator attached ? 1 Answer
Play animation OnTriggerEnter (C#) 1 Answer
Animation error (Last time I'm asking) 2 Answers
Play animation OnTriggerEnter (C#) 1 Answer
Model has Animator, how do I force start an animation, and tell where it is? (C#) 1 Answer