123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.Playables;
- public class TimeLineChange : MonoBehaviour {
- public PlayableDirector mDirector;
- public GameObject mGame2;
- public TimelinePauseByTime mGamePauseObj;
- private bool StopAndFirstFream = false;
- public void Start()
- {
- mDirector.gameObject.SetActive(false);
- mGame2.SetActive(false);
- mGamePauseObj = mGame2.GetComponent<TimelinePauseByTime>();
- }
- public void CloseAllTimeLine()
- {
- TimeLineStop();
- mDirector.gameObject.SetActive(false);
- mGame2.SetActive(false);
- }
- public void SwitchDirector(TimeLineControlType ControlType)
- {
- if (ControlType == TimeLineControlType.E_Explain)
- {
- mDirector.gameObject.SetActive(true);
- TimeLinePlay();
- StopAndFirstFream = true;
- //Invoke("TimeLinePause", 0.1f);
- mGame2.SetActive(false);
- }
- else
- {
- mDirector.gameObject.SetActive(false);
- TimeLinePlay();
- StopAndFirstFream = true;
- //Invoke("TimeLinePause", 0.1f);
- mGame2.SetActive(true);
- if (mGamePauseObj != null)
- {
- mGamePauseObj.InitTaskCanvas();
- }
- }
- }
- public double GetLength()
- {
- return mDirector.duration;
- }
- public double GetCurrentTime()
- {
- return mDirector.time;
- }
- void _play()
- {
- if (!mDirector.gameObject.activeSelf)
- {
- mDirector.gameObject.SetActive(true);
- }
- mDirector.Play();
- }
- public void TimeLineRePlay()
- {
- mDirector.Stop();
- mDirector.time = 0;
- _play();
- }
- public void TimeLinePlay()
- {
- _play();
- }
- public void TimeLinePause()
- {
- mDirector.Pause();
- }
- public void TimeLineStop()
- {
- mDirector.Stop();
- }
- public void SetTime(float ratio)
- {
- mDirector.Pause();
- mDirector.time = mDirector.duration * ratio;
- _play();
- }
- public void Update()
- {
- if (StopAndFirstFream)
- {
- if (mDirector.time > 0.0f)
- {
- TimeLinePause();
- StopAndFirstFream = false;
- }
- }
- if (mDirector.time >= mDirector.duration)
- {
- if (mDirector.gameObject.activeSelf)
- {
- mDirector.gameObject.SetActive(false);
- }
- }
- }
- }
|