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

71 行
2.1 KiB

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
namespace HuaweiHmsDemo
{
public class TestView : MonoBehaviour
{
public bool AdsEnabled;
public bool AnalyticEnabled;
public bool PushEnabled;
public bool LocationEnabled;
public bool RemoteConfigEnabled;
public bool AppLinkingEnabled;
public bool AppMessageEnabled;
public bool CrashEnabled;
public Transform btnParent;
public GameObject btnPrefab;
public TestTip testTip;
private int index = 1;
public int start = 0;
public int space = 40;
public void Start()
{
Initial();
}
public void Initial(){
Screen.SetResolution (1080, 2340,true); // hack
if(AdsEnabled){
AdsTest.GetInstance().RegisterEvent(RegistEvent);
}
if(AnalyticEnabled){
AnalyticTest.GetInstance().RegisterEvent(RegistEvent);
}
if(PushEnabled){
PushTest.GetInstance().RegisterEvent(RegistEvent);
}
if(LocationEnabled){
LocationTest.GetInstance().RegisterEvent(RegistEvent);
}
if(RemoteConfigEnabled){
RemoteConfigTest.GetInstance().RegisterEvent(RegistEvent);
}
if (AppLinkingEnabled)
{
AppLinkingTest.GetInstance().RegisterEvent(RegistEvent);
}
if (AppMessageEnabled)
{
AppMessageTest.GetInstance().RegisterEvent(RegistEvent);
}
if (CrashEnabled)
{
CrashTest.GetInstance().RegisterEvent(RegistEvent);
}
}
public void RegistEvent(string text,UnityAction action)
{
var btnClone = Instantiate(btnPrefab, btnParent);
var btn = btnClone.GetComponent<TestBtn>();
btn.transform.localPosition = new Vector3(0, start - space * index, 0);
btn.Init(text,action);
index++;
}
}
}