3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

TimelineでMarkerを配置するためのTrackを作る

Last updated at Posted at 2023-07-02

Markerを配置できる場所には、TimelineのMarkerTrackとGameObjectをバインドしたTrackの2つがある。

後者を使うことでGameObjectを個別に制御できる

INotificationReceiverを実装したクラスをTrackAssetクラスを継承したクラスのTrackBindingType属性に設定すればいい

例えば、全てのリストに設定したゲームオブジェクトをアクティブにするには以下の通りに書く
通知を受け取る側は、MonoBehaviourを継承しているのでGameObjectに対してどんな処理でもできる

using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

public class CustomMarker : Marker, INotification
{
    PropertyName INotification.id { get; }
}
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;

public class CustomReceiver : MonoBehaviour, INotificationReceiver
{

    void INotificationReceiver.OnNotify(Playable origin, INotification notification, object context)
    {
        if(notification is PlatoonEncounter marker)
        {
            Activate();
        }
    }

    public List<GameObject> gameObjects = new List<GameObject>();

    void Activate()
    {
        gameObjects.ForEach(_ => _.SetActive(true));
    }
}
using UnityEngine.Timeline;

[TrackBindingType(typeof(CustomReceiver))] // この属性でどのゲームオブジェクトが通知を受け取るか指定できる
public class CustomTrack : TrackAsset {}   // クラス名がTrackの名前になる
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?