131 lines
2.8 KiB
C#
131 lines
2.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using Newtonsoft.Json;
|
|
using System.IO;
|
|
using UnityEngine.EventSystems;
|
|
using Unity.VisualScripting;
|
|
using static RobotManager;
|
|
using System;
|
|
|
|
public enum RobotePanelEnum
|
|
{
|
|
RecordPanel,//开始录音面板
|
|
RecordKingPanel,//正在录音面板
|
|
RecordEndPanel,//录音结束面板
|
|
RecordDebugPanel,//识别面板
|
|
CustomPanel,//自定义动作面板
|
|
PhotoPanel,//照片面板
|
|
TextToSpeekPanel//文本转语音面板
|
|
}
|
|
public class RobotUI
|
|
{
|
|
|
|
public int recordTime;
|
|
public GameObject robot;
|
|
private static RobotUI instance;
|
|
public Dictionary<string, GameObject> panelDic;
|
|
|
|
public static RobotUI Instance
|
|
{
|
|
get
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = new RobotUI();
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
public void Init(GameObject _obj = null)
|
|
{
|
|
panelDic = new Dictionary<string, GameObject>();
|
|
robot = _obj;
|
|
if (robot != null)
|
|
{
|
|
if (robot.GetComponent<MicroPhoneManager>() != null)
|
|
{
|
|
robot.GetComponent<MicroPhoneManager>().Init();
|
|
}
|
|
}
|
|
recordTime = 0;
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public GameObject OpenPanel(string _name)
|
|
{
|
|
if (panelDic != null && panelDic.ContainsKey(_name))
|
|
{
|
|
panelDic[_name].SetActive(true);
|
|
return panelDic[_name];
|
|
}
|
|
else
|
|
{
|
|
GameObject panel = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/UIItem/" + _name), GameObject.Find("MainCanvas").transform);
|
|
panelDic.Add(_name, panel);
|
|
return panel;
|
|
}
|
|
}
|
|
public void ClosePanel(string _name)
|
|
{
|
|
if (panelDic.ContainsKey(_name))
|
|
{
|
|
Debug.Log("关闭" + _name + "成功");
|
|
panelDic[_name].SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("关闭面板失败");
|
|
}
|
|
}
|
|
internal void StartRedord()
|
|
{
|
|
robot.GetComponent<Robot>().StartRedord();
|
|
}
|
|
internal bool StopRecord()
|
|
{
|
|
bool flag= robot.GetComponent<Robot>().StopRecord();
|
|
return flag;
|
|
}
|
|
internal void Audition()
|
|
{
|
|
robot.GetComponent<Robot>().Audition();
|
|
}
|
|
internal void StopAudition()
|
|
{
|
|
robot.GetComponent<Robot>().Audition();
|
|
}
|
|
internal void Recognition()
|
|
{
|
|
robot.GetComponent<Robot>().Recognition();
|
|
}
|
|
|
|
internal void Anew()
|
|
{
|
|
robot.GetComponent<Robot>().Anew();
|
|
}
|
|
|
|
internal void EndRecord()
|
|
{
|
|
robot.GetComponent<Robot>().EndRecord();
|
|
}
|
|
}
|