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 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(); robot = _obj; if (robot != null) { if (robot.GetComponent() != null) { robot.GetComponent().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("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().StartRedord(); } internal bool StopRecord() { bool flag= robot.GetComponent().StopRecord(); return flag; } internal void Audition() { robot.GetComponent().Audition(); } internal void StopAudition() { robot.GetComponent().Audition(); } internal void Recognition() { robot.GetComponent().Recognition(); } internal void Anew() { robot.GetComponent().Anew(); } internal void EndRecord() { robot.GetComponent().EndRecord(); } }