Skip to content

Instantly share code, notes, and snippets.

@am1tanaka
Created December 29, 2018 16:23
Show Gist options
  • Select an option

  • Save am1tanaka/268c571994b974721274c0424a6563dd to your computer and use it in GitHub Desktop.

Select an option

Save am1tanaka/268c571994b974721274c0424a6563dd to your computer and use it in GitHub Desktop.
UnityのTimelineが終了したら、OnEndに登録した処理を呼び出すスクリプト
using UnityEngine;
using UnityEngine.Events;
namespace AM1
{
/// <summary>
/// TimelineにActivation Trackを追加して、アニメーションが終了した時に、検出用のオブジェクトが無効になるようにします。
/// そのオブジェクトにこのスクリプトをアタッチします。
/// オブジェクトを無効にしたのと同時にTimelineが終わるとOnDisableが呼び出されないので、
/// 終了後のアニメーションを引き延ばしておく。
/// </summary>
public class TimelineEndDetector : MonoBehaviour
{
[Tooltip("終了時に呼び出すメソッド"), SerializeField]
UnityEvent OnEnd;
private void OnDisable()
{
OnEnd.Invoke();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment