40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
public class OfficeTimelineControl : MonoBehaviour
|
|
{
|
|
private PlayableDirector mPlayableDirector;
|
|
|
|
//过场动画所用的玩家模型
|
|
private GameObject playerModel;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
mPlayableDirector = GetComponent<PlayableDirector>();
|
|
mPlayableDirector.Stop();
|
|
playerModel = transform.GetChild(0).gameObject;
|
|
mPlayableDirector.stopped += OnPlayableDirectorStopped;
|
|
StartTimeline();//TODO 这里先掉一下,后续应该流程控制的时候触发调用
|
|
}
|
|
|
|
public void StartTimeline()
|
|
{
|
|
mPlayableDirector.Play();
|
|
}
|
|
|
|
private void OnPlayableDirectorStopped(PlayableDirector aDirector)
|
|
{
|
|
if (mPlayableDirector == aDirector)
|
|
{
|
|
Destroy(playerModel);
|
|
}
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
mPlayableDirector.stopped -= OnPlayableDirectorStopped;
|
|
}
|
|
} |