75 lines
1.7 KiB
C#
75 lines
1.7 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;
|
|
}
|
|
}
|
|
|
|
/// <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;
|
|
}
|
|
|
|
}
|