
ランダムな数字を表示するスクリプトをタイムラインから簡単に実行してみます。
まず、プロジェクトウィンドウで右クリックからSignalを新規作成します。

タイムライン上のメソッドを呼び出したいところにこのシグナルを置くことになります。
空のゲームオブジェクトを作って、タイムラインウィンドウでCreateボタンをクリックします。

同じオブジェクトでも良いですが、今回は空のゲームオブジェクトをもう一つ作って、タイムラインを作ったオブジェクトを選択した状態で、新しく作った方をタイムラインの左側の下部のなにもないところにドラッグアンドドロップします。
すると、メニューがでるのでAdd Signal Trackをクリックします。

このオブジェクトにはスクリプトを付けて、ランダムな数字を表示するpublicメソッドを作っておきます。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TimelineTestScript : MonoBehaviour
{
[SerializeField] Text text;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void DisplayNumber()
{
text.text = Random.Range(0, 100).ToString();
}
}
シグナルトラックを追加すると、このゲームオブジェクトにSignal Receiverコンポーネントが追加されるので、インスペクタでAdd Reactionボタンをクリックします。

Signalの項目で最初に作ったシグナルを選択し、Reactionの+ボタンを押します。

No Functionと表示されたプルダウンメニューから、このシグナルによって実行しない関数を選択します。

プロジェクトウィンドウから、最初に作ったシグナルをタイムラインのシグナルトラックにドラッグアンドドロップします。選択した関数を実行したい場所に配置します。

これで簡単にタイムラインからスクリプトを実行できました。
