本演示项目在Unity for Android Build中启用部分华为HMS和AGC服务,对应的类和函数的名称和用法相同。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

68 行
2.5 KiB

using System.Collections;
using System.Collections.Generic;
using HuaweiAuthDemo;
using HuaweiService.Auth;
using UnityEngine;
using UnityEngine.UI;
namespace HuaweiAuthDemo
{
public class LinkThirdParty : AbstractPanel
{
void Start()
{
var buttons = GetComponentsInChildren<Button>();
foreach (var button in buttons)
{
if (button.name == "HWID")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.HMS_Provider));
}
else if (button.name == "HWGame")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.HWGame_Provider));
}
else if (button.name == "Wechat")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.WeiXin_Provider));
}
else if (button.name == "Facebook")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.Facebook_Provider));
}
else if (button.name == "Twitter")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.Twitter_Provider));
}
else if (button.name == "weibo")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.WeiBo_Provider));
}
else if (button.name == "QQ")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.QQ_Provider));
}
else if (button.name == "Google")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.Google_Provider));
}
else if (button.name == "GooglePlay")
{
button.onClick.AddListener(() => OnLinkClicked(AGConnectAuthCredential.GoogleGame_Provider));
}
}
}
public void OnLinkClicked(int provider)
{
DetailLogin.Provider = provider;
PanelController.getInstance().GetComponentInChildren<DetailLogin>().ParentPanel = this;
PanelController.getInstance()
.OpenPanel(PanelController.getInstance().GetComponentInChildren<DetailLogin>());
}
}
}