(020)Unity3d 脚本播放Timeline
Timeline
·
预制体

脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
public class TimeLineDirector : MonoBehaviour
{
[SerializeField]
private PlayableDirector _director;
private float _animationTime = 10f;
// Start is called before the first frame update
void Start()
{
_director.gameObject.SetActive(false);
_director.Stop();
_director.initialTime = 0;
_animationTime = 300 / 60f;
}
public void Play()
{
_director.gameObject.SetActive(true);
_director.initialTime = 0;
_animationTime = 300 / 60f;
_director.Play();
}
// Update is called once per frame
void Update()
{
if (_director.time >= _animationTime)
{
_director.Stop();
gameObject.SetActive(false);
}
}
}
更多推荐




所有评论(0)