90 lines
2.5 KiB
C#
90 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
using UnityEngine.UI;
|
|
using XFrame.Core.UI;
|
|
|
|
public class NDStartLoad : MonoBehaviour
|
|
{
|
|
|
|
[HideInInspector]
|
|
public bool isBlack = false;//不透明状态
|
|
[HideInInspector]
|
|
private float fadeSpeed = 5f;//透明度变化速率
|
|
public RawImage rawImage;
|
|
public RectTransform rectTransform;
|
|
|
|
public FirstPersonController firstControl;
|
|
public GameObject ManagerObject;
|
|
public GameObject Canvas;
|
|
public GameObject carHuman;
|
|
public GameObject carHuman2;
|
|
|
|
public GameObject skipBtn;
|
|
/// <summary>
|
|
/// 场景时间动画控制器
|
|
/// </summary>
|
|
private PlayableDirector player;
|
|
|
|
private bool isChenck = false;
|
|
|
|
|
|
void Start()
|
|
{
|
|
player = transform.GetComponent<PlayableDirector>();
|
|
rectTransform.sizeDelta = new Vector2(Screen.width, Screen.height);//使背景满屏
|
|
rawImage.color = Color.clear;
|
|
isBlack = false;
|
|
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (isChenck)
|
|
{
|
|
if (isBlack)
|
|
{
|
|
rawImage.color = Color.Lerp(rawImage.color, Color.black, Time.deltaTime * fadeSpeed);//渐暗
|
|
if (rawImage.color.a > 0.98f)
|
|
{
|
|
rawImage.color = Color.black;
|
|
transform.GetChild(0).gameObject.SetActive(false);
|
|
carHuman.SetActive(false);
|
|
carHuman2.SetActive(false);
|
|
firstControl.enabled = true;
|
|
ManagerObject.SetActive(true);
|
|
Canvas.SetActive(true);
|
|
player.Pause();
|
|
isBlack = false;
|
|
XUIPanel.ShowPanel<MiniMapPanel>();
|
|
if (ExamDataPanel.instance == null)
|
|
{
|
|
XUIPanel.ShowPanel<ExamDataPanel>();
|
|
}
|
|
ExamDataPanel.instance.StartCountDown();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
rawImage.color = Color.Lerp(rawImage.color, Color.clear, Time.deltaTime * fadeSpeed * 0.5f);//渐亮
|
|
|
|
if (rawImage.color.a < 0.05f)
|
|
{
|
|
rawImage.color = Color.clear;
|
|
rawImage.gameObject.SetActive(false);
|
|
this.enabled = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnTimelineEnd()
|
|
{
|
|
skipBtn.SetActive(false);
|
|
rawImage.gameObject.SetActive(true);
|
|
isBlack = true;
|
|
isChenck = true;
|
|
}
|
|
}
|