68 lines
1.9 KiB
C#
68 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System.Linq;
|
|
using UnityEngine.Playables;
|
|
|
|
public class SkipTimeline : MonoBehaviour
|
|
{
|
|
Button skipBtn;
|
|
public bool m_SkipTime = false;
|
|
public PlayableDirector director;
|
|
public NDStartLoad ndStartload;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
skipBtn = GetComponent<Button>();
|
|
skipBtn.onClick.AddListener(() =>
|
|
{
|
|
if (m_SkipTime)
|
|
{
|
|
if (director)
|
|
{
|
|
//director.time = director.duration;
|
|
Invoke("EndTime", 0.1f);
|
|
if(ndStartload)ndStartload.OnTimelineEnd();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var asyncLoadings = FindObjectsOfType<AsyncLoadingScene>().ToList();
|
|
var async = asyncLoadings.Find(x => x.Async != null);
|
|
if (async != null)
|
|
async.LoadScene();
|
|
}
|
|
//操作后隐藏按钮自身
|
|
gameObject.SetActive(false);
|
|
});
|
|
if (GameManage.skipCaiAnim == true)
|
|
{
|
|
if (director)
|
|
{
|
|
//director.time = director.duration;
|
|
Invoke("EndTime", 0.1f);
|
|
skipBtn.gameObject.SetActive(false);
|
|
GameManage.skipCaiAnim = false;
|
|
//if (ndStartload) ndStartload.OnTimelineEnd();
|
|
}
|
|
Debug.Log("跳过动画");
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (m_SkipTime)
|
|
{
|
|
if (gameObject.activeSelf && Mathf.Abs((float)director.time - (float)director.duration) < 0.5f)
|
|
{
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
void EndTime()
|
|
{
|
|
director.time = director.duration;
|
|
}
|
|
} |