96 lines
2.3 KiB
C#
96 lines
2.3 KiB
C#
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_TeacherStudentPanel : BasePanel
|
|
{
|
|
public Button LeftBtn; //左侧大按钮
|
|
public Button CloseBtn; //关闭按钮
|
|
public TMP_InputField AskInputField; //提问框
|
|
|
|
public Button CommentBtn; //提交评论按钮
|
|
private CanvasGroup canvasGroup ; //
|
|
private GameObject Player;
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
OnInit();
|
|
}
|
|
|
|
public void OnInit()
|
|
{
|
|
LeftBtn = GetControl<Button>("左侧大按钮");
|
|
CloseBtn = GetControl<Button>("关闭按钮");
|
|
AskInputField = GetControl<TMP_InputField>("提问框");
|
|
CommentBtn = GetControl<Button>("评论按钮");
|
|
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);
|
|
}
|
|
|
|
public override void HideMe()
|
|
{
|
|
base.HideMe();
|
|
FadeOut(0.5f);
|
|
}
|
|
protected override void OnClick(string btnPath)
|
|
{
|
|
|
|
base.OnClick(btnPath);
|
|
switch (btnPath)
|
|
{
|
|
case "左侧大按钮":
|
|
FadeOut(0.5f);
|
|
Player.GetComponent<FirstPersonController>().enabled = true;
|
|
break;
|
|
case "关闭按钮":
|
|
FadeOut(0.5f);
|
|
Player.GetComponent<FirstPersonController>().enabled = true;
|
|
break;
|
|
case "评论按钮":
|
|
Comment();
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击评论
|
|
/// </summary>
|
|
public void Comment()
|
|
{
|
|
//将问题提交后台
|
|
RepairSenderManager.Instance.OnClickSend(AskInputField);
|
|
AskInputField.text = "";
|
|
}
|
|
}
|
|
|