85 lines
2.9 KiB
C#
85 lines
2.9 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Stary.Evo;
|
|
using Stary.Evo.RKTools;
|
|
using Stary.Evo.UIFarme;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using YooAsset;
|
|
|
|
namespace Main
|
|
{
|
|
public class DomainPanel : BasePanel, IBasePanel
|
|
{
|
|
public override UITweenType TweenType => UITweenType.Fade;
|
|
|
|
private string[] domains;
|
|
|
|
private GameObject[] _domainGrids;
|
|
|
|
public override async Task InitializeAsync(GameObject panelGo)
|
|
{
|
|
await base.InitializeAsync(panelGo);
|
|
domains = await ArtLoadAssetServer.GetServerDomainAllName();
|
|
_domainGrids = new GameObject[domains.Length];
|
|
if (domains != null)
|
|
{
|
|
var package = YooAssets.TryGetPackage("Main");
|
|
var handle = package.LoadAssetAsync<GameObject>(R.Res.Main.prefabs.viewbg_prefab);
|
|
await handle.Task;
|
|
// float count = domains.Length / 2f;
|
|
// float x = (-70 * count) + 35;
|
|
var grid = this.activePanel.transform.Find("Grid");
|
|
for (int i = 0; i < domains.Length; i++)
|
|
{
|
|
// x += (70 * i);
|
|
var viewBg =
|
|
handle.InstantiateSync();
|
|
viewBg.transform.SetParent(grid);
|
|
viewBg.transform.localPosition = Vector3.zero;
|
|
viewBg.transform.localRotation = Quaternion.identity;
|
|
viewBg.transform.localScale = Vector3.one;
|
|
viewBg.transform.Find("Text").GetComponent<TextMeshProUGUI>().text = domains[i];
|
|
viewBg.name = domains[i];
|
|
_domainGrids[i] = viewBg;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnEnter(Action complete = null)
|
|
{
|
|
StringEventSystem.Global.Send("X_ButtonHierarchyType",DeviceXEventHandler.HierarchyType.Domain);
|
|
for (int i = 0; i < _domainGrids.Length; i++)
|
|
{
|
|
_domainGrids[i].gameObject.ObjectAddTouchEvent(OnTouchComplete);
|
|
}
|
|
|
|
base.OnEnter(complete);
|
|
}
|
|
|
|
private async void OnTouchComplete(GameObject go)
|
|
{
|
|
for (int i = 0; i < _domainGrids.Length; i++)
|
|
{
|
|
_domainGrids[i].gameObject.ObjectPauseTouchEvent();
|
|
}
|
|
|
|
HybridClREntrance.Global.domain = go.name;
|
|
await HybridClREntrance.Global.OpenDomain();
|
|
|
|
await this.GetSystem<IPanelSystem>()
|
|
.PushStack<ScenePanel>(packageName: "Main", parent: panelParent.transform);
|
|
this.GetSystem<IPanelSystem>().SendEvent("SetSceneData", go.name);
|
|
}
|
|
|
|
public override void OnExit(float delay = 0f)
|
|
{
|
|
for (int i = 0; i < _domainGrids.Length; i++)
|
|
{
|
|
_domainGrids[i].gameObject.ObjectRemoveTouchEvent();
|
|
}
|
|
|
|
base.OnExit(delay);
|
|
}
|
|
}
|
|
} |