123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- using Newtonsoft.Json;
- using ShadowStudio.Mgr;
- using Studio.Scripts;
- using Studio.Scripts.HttpMessage;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using XRTool.Util;
- using XRTool.WorldUI;
- namespace ShadowStudio.UI
- {
- [RequireComponent(typeof(WorldDlg))]
- public class AboutMeDlg : UnitySingleton<AboutMeDlg>
- {
- WorldDlg dlg;
- private XRIcon avatar;
- private TextMesh userNameText;
- private Toggle cameraToggle_Switch;
- private Toggle micToggle_Switch;
- private Transform toggleGroupTran;
- private Transform framerateToggleGroup;
- private Button loginoutBtn;
- private Button closeBtn;
- void Start()
- {
- dlg = GetComponent<WorldDlg>();
- avatar = dlg.GetBreadthChild<XRIcon>("Avatar");
- for (int i = 0; i < CommonMethod.UserAvatarsList.Count; i++)
- {
- if (UserInfoMgr.Instance.userConfig.Avatar == CommonMethod.UserAvatarsList[i].Url)
- {
- string path = "Avatar/" + CommonMethod.UserAvatarsList[i].Id + "Avatar";
- avatar.icon = Resources.Load(path) as Texture2D;
- avatar.AutoSetSprite();
- }
- }
- userNameText = dlg.GetBreadthChild<TextMesh>("UserNameText");
- userNameText.text = UserInfoMgr.Instance.userConfig.Nick_name;
- cameraToggle_Switch = dlg.GetBreadthChild<Toggle>("CameraXRToggle_Switch");
- micToggle_Switch = dlg.GetBreadthChild<Toggle>("MicXRToggle_Switch");
- toggleGroupTran = dlg.GetBreadthChild<Transform>("ResolutionToggleGroup");
- framerateToggleGroup = dlg.GetBreadthChild<Transform>("FramerateToggleGroup");
- closeBtn = dlg.GetBreadthChild<Button>("CloseBtn");
- closeBtn.onClick.AddListener(OnClickClose);
- loginoutBtn = dlg.GetBreadthChild<Button>("LoginOutBtn");
- loginoutBtn.onClick.AddListener(OnClickLoginout);
- cameraToggle_Switch.onValueChanged.AddListener(ClickCamearaToggle);
- micToggle_Switch.onValueChanged.AddListener(ClickMicToggle);
- XRToggle[] toggles = toggleGroupTran.GetComponentsInChildren<XRToggle>(true);
- for (int i = 0; i < toggles.Length; i++)
- {
- XRToggle toggle = toggles[i];
- toggles[i].onValueChanged.AddListener((bool isOn) => { OnToggle(isOn, toggle); });
- if (i == CommonMethod.mySetting.Ratio - 1)
- {
- toggles[i].isOn = true;
- OnToggle(true, toggles[i]);//记得初始化
- }
- }
- XRToggle[] togglegroup = framerateToggleGroup.GetComponentsInChildren<XRToggle>(true);
- for (int i = 0; i < togglegroup.Length; i++)
- {
- XRToggle toggle = togglegroup[i];
- togglegroup[i].onValueChanged.AddListener((bool isOn) => { OnFrameToggle(isOn, toggle); });
- if (i == CommonMethod.mySetting.Fps - 1)
- {
- togglegroup[i].isOn = true;
- OnFrameToggle(true, togglegroup[i]);
- }
- }
- if (CommonMethod.mySetting.Camera)
- {
- cameraToggle_Switch.isOn = true;
- }
- else
- {
- cameraToggle_Switch.isOn = false;
- }
- if (CommonMethod.mySetting.Mic)
- {
- micToggle_Switch.isOn = true;
- }
- else
- {
- micToggle_Switch.isOn = false;
- }
- CustomInfo.isSendVideo = cameraToggle_Switch.isOn;
- CustomInfo.isSendAudio = micToggle_Switch.isOn;
- }
- private void ClickCamearaToggle(bool isOn)
- {
- CommonMethod.mySetting.Camera = isOn;
- CustomInfo.isSendVideo = isOn;
- //Debug.Log(CommonMethod.mySetting.Camera + "Camera" + isOn);
- SystemDatas data = new SystemDatas();
- data.Camera = CustomInfo.isSendVideo ? 1 : 0;
- data.Mic = CustomInfo.isSendAudio ? 1 : 0;
- SaveSystemData(data);
- }
- private void ClickMicToggle(bool isOn)
- {
- CommonMethod.mySetting.Mic = isOn;
- CustomInfo.isSendAudio = isOn;
- //Debug.Log(CommonMethod.mySetting.Mic + "Mic" + isOn);
- SystemDatas data = new SystemDatas();
- data.Camera = CustomInfo.isSendVideo ? 1 : 0;
- data.Mic = CustomInfo.isSendAudio ? 1 : 0;
- SaveSystemData(data);
- }
- private void SaveSystemData(SystemDatas data)
- {
- UserInfo.systemDatas = data;
- string saveData = JsonConvert.SerializeObject(data);
- Debug.Log(saveData);
- PlayerPrefs.SetString(UserInfo.Account + "_SystemSetting", saveData);
- }
-
- private void OnToggle(bool isOn, XRToggle toggle)
- {
- if (isOn)
- {
- switch (toggle.name)
- {
- case "HighXRToggle_CheckBox":
- CommonMethod.mySetting.Ratio = 1;
- //Debug.Log("HighResolutionBtn");
- break;
- case "MidXRToggle_CheckBox":
- CommonMethod.mySetting.Ratio = 2;
- //Debug.Log("MidResolutionBtn");
- break;
- case "LowXRToggle_CheckBox":
- CommonMethod.mySetting.Ratio = 3;
- //Debug.Log("LowResolutionBtn");
- break;
- }
- }
- }
- private void OnFrameToggle(bool isOn, XRToggle toggle)
- {
- if (isOn)
- {
- switch (toggle.name)
- {
- case "15XRToggle_CheckBox":
- CommonMethod.mySetting.Fps = 3;
- break;
- case "30XRToggle_CheckBox":
- CommonMethod.mySetting.Fps = 2;
- break;
- case "60XRToggle_CheckBox":
- CommonMethod.mySetting.Fps = 1;
- break;
- }
- }
- }
- private void OnClickClose()
- {
- dlg.hideDlg(() => {
- //被zby替换的代码
- //RoomListModel.Instance.UpdateList(RoomListDlg.Instance.roomlist);
- //HomeViewMgr.Instance.ShowView(HomeViewMgr.CREATESEARCHRROOMDLG);
- //HomeViewMgr.Instance.roomListDlg.SetActive(true);
- MenuListDlg.Instance.UpdateData();
- HomeMgr.Instance.ShowView(HomeMgr.CREATESEARCHRROOMDLG);
- HomeMgr.Instance.roomListDlg.SetActive(true);
- });
- HomeProxy.Instance.RequestUpdateSettings(CommonMethod.mySetting.Camera,
- CommonMethod.mySetting.Mic,
- (RatioType)CommonMethod.mySetting.Ratio,
- (FpsType)CommonMethod.mySetting.Fps);
- }
- private void OnClickLoginout()
- {
- WSHandler.clientClosed();
- //被zby替换的代码
- //HomeViewMgr.Instance.LoadLoginSence();
- HomeMgr.Instance.LoadLoginSence();
- HomeProxy.Instance.RequestUpdateSettings(CommonMethod.mySetting.Camera,
- CommonMethod.mySetting.Mic,
- (RatioType)CommonMethod.mySetting.Ratio,
- (FpsType)CommonMethod.mySetting.Fps);
- }
- }
- }
|