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

49 行
1.4 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 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().RegistEvent(RegistEvent);
}
if(AnalyticEnabled){
AnalyticTest.GetInstance().RegistEvent(RegistEvent);
}
if(PushEnabled){
PushTest.GetInstance().RegistEvent(RegistEvent);
}
if(LocationEnabled){
LocationTest.GetInstance().RegistEvent(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++;
}
}
}