ND_SimulationAutomaticControl/Assets/Scripts/UI/UIPanel/UI_OpenFilePanel.cs

87 lines
2.2 KiB
C#

using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class UI_OpenFilePanel : BasePanel
{
public Button CloseBtn; //关闭按钮
private CanvasGroup canvasGroup; //屏幕显示
public Transform contentTrans; //生成父物体
public UI_File UIFile; //生成的资料子物体
private GameObject Player;
protected override void Awake()
{
base.Awake();
OnInit();
}
public void OnInit()
{
CloseBtn = GetControl<Button>("CloseBtn");
canvasGroup = GetComponent<CanvasGroup>();
canvasGroup.alpha = 0f; // 默认隐藏
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
Player = GameObject.FindGameObjectWithTag("Player");
}
public override void ShowMe()
{
base.ShowMe();
FadeIn(0.5f);
Player = GameObject.FindGameObjectWithTag("Player");
}
public override void HideMe()
{
base.HideMe();
FadeOut(0.5f);
}
protected override void OnClick(string btnPath)
{
base.OnClick(btnPath);
switch (btnPath)
{
case "CloseBtn":
FadeOut(0.5f);
Player.GetComponent<FirstPersonController>().enabled = true;
break;
//测试打开文件面板用
case "UI_File文件按钮":
Debug.Log("UI_File文件按钮____________________");
break;
//测试视屏面板用
case "UI_File视频按钮":
Debug.Log("UI_File视频按钮++++++++++++++++++++");
Bootstrap.Instance.uiManager.ShowPanel<UI_VideoPanel>(this, E_UI_Layer.Top, (panel) =>
{
Debug.Log("场景加载成功");
});
break;
}
}
/// <summary>
/// 提问渐显
/// </summary>
public void FadeIn(float time)
{
canvasGroup.DOFade(1f, time);
canvasGroup.interactable = true;
canvasGroup.blocksRaycasts = true;
}
/// <summary>
/// 提问渐隐
/// </summary>
public void FadeOut(float time)
{
canvasGroup.DOFade(0f, time);
canvasGroup.interactable = false;
canvasGroup.blocksRaycasts = false;
}
}