(020)Unity3d 脚本播放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);
}
}
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)