Open1
[Unity] AnimationEvent追加
AddEventTrigger
private void SetUpEventTrigger()
{
EventTrigger trigger = gameObject.GetComponent<EventTrigger>();
EventTrigger.Entry entry = new EventTrigger.Entry();
entry.eventID = EventTriggerType.PointerClick;
entry.callback.AddListener((eventDate) => { OnClickObj(); });
trigger.triggers.Add(entry);
}
AddAnimationEvent
public class AnimationEventTest : MonoBehaviour
{
[SerializeField] private AnimationClip _testClip;
public void AddAnimEvent()
{
// アニメーションイベントの作成
AnimationEvent animEvent = new AnimationEvent();
// BattleStandby
if (_testClip != null)
{
animEvent.functionName = "TestEvent";
animEvent.time = _testClip / 2;
_testClip.AddEvent(animEvent);
}
}
}