134 lines
3.1 KiB
C#
134 lines
3.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.InteropServices;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class UserPanel : BasePanel, ISelectHandler
|
|
{
|
|
//用户头像
|
|
public Image imgUserHead;
|
|
|
|
//音效
|
|
public Toggle togSound;
|
|
//震动
|
|
public Toggle togClose;
|
|
//个性化推荐
|
|
public Toggle togPersonal;
|
|
|
|
//退出界面
|
|
public Button btnQuit;
|
|
//复制邀请码
|
|
public Button btnCopyYQM;
|
|
//复制qq群号
|
|
public Button btnCopyQQ;
|
|
//用户协议
|
|
public Button btnXY;
|
|
//隐私政策
|
|
public Button btnZC;
|
|
//关于我们
|
|
public Button btnGY;
|
|
//检查更新
|
|
public Button btnGX;
|
|
//注销账号
|
|
public Button btnZX;
|
|
//退出登录
|
|
public Button btnTC;
|
|
//邀请码提交
|
|
public Button btnSubmit;
|
|
|
|
//用户名
|
|
public Text txtUserName;
|
|
//邀请码
|
|
public Text txtYQM;
|
|
//qq群号
|
|
public Text txtQQ;
|
|
|
|
//邀请码输入框
|
|
public InputField inputYQM;
|
|
|
|
// 声明外部JS函数
|
|
[DllImport("__Internal")]
|
|
private static extern void CopyToClipboardJS(string text);
|
|
|
|
public override void Init()
|
|
{
|
|
//更新面板
|
|
UpdatePanel();
|
|
|
|
btnQuit.onClick.AddListener(() =>
|
|
{
|
|
UIManager.Instance.HidePanel<UserPanel>();
|
|
});
|
|
btnTC.onClick.AddListener(() =>
|
|
{
|
|
SceneManager.LoadScene("LoginScene");
|
|
UIManager.Instance.HidePanel<GamePanel>(false);
|
|
UIManager.Instance.HidePanel<UserPanel>(false);
|
|
GameMgr.Instance.petList.Clear();
|
|
PoolMgr.Instance.ClearPool();
|
|
GC.Collect();
|
|
});
|
|
|
|
btnSubmit.onClick.AddListener(() =>
|
|
{
|
|
if (inputYQM.text != null)
|
|
{
|
|
InviteMsg msg = new InviteMsg();
|
|
msg.openId = GameDataMgr.Instance.player.openId;
|
|
msg.invitePerson = inputYQM.text;
|
|
StartCoroutine(NetMgr.Instance.InvitePost(msg));
|
|
}
|
|
inputYQM.text = null;
|
|
});
|
|
|
|
btnCopyYQM.onClick.AddListener(CopyYQMToClipboard);
|
|
btnCopyQQ.onClick.AddListener(CopyQQToClipboard);
|
|
togSound.onValueChanged.AddListener((v) =>
|
|
{
|
|
//让背景音乐进行开关
|
|
BKMusic.Instance.SetIsOpen(v);
|
|
//记录音效的开关数据
|
|
GameDataMgr.Instance.musicData.isOpen = v;
|
|
});
|
|
|
|
}
|
|
|
|
void CopyYQMToClipboard()
|
|
{
|
|
// 获取UI文本
|
|
string textToCopy = txtYQM.text;
|
|
|
|
// 仅在WebGL平台调用
|
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
|
CopyToClipboardJS(textToCopy);
|
|
#endif
|
|
}
|
|
|
|
void CopyQQToClipboard()
|
|
{
|
|
// 获取UI文本
|
|
string textToCopy = txtQQ.text;
|
|
|
|
// 仅在WebGL平台调用
|
|
#if UNITY_WEBGL && !UNITY_EDITOR
|
|
CopyToClipboardJS(textToCopy);
|
|
#endif
|
|
}
|
|
|
|
|
|
//更新面板
|
|
private void UpdatePanel()
|
|
{
|
|
txtUserName.text = GameDataMgr.Instance.player.username;
|
|
txtYQM.text = "邀请码:"+GameDataMgr.Instance.player.openId;
|
|
}
|
|
public void OnSelect(BaseEventData eventData)
|
|
{
|
|
inputYQM.text = "";
|
|
}
|
|
}
|