powerfun-unity/Assets/StartRideModal.cs

48 lines
1.7 KiB
C#

using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class StartRideModal : PFUIPanel
{
private Dictionary<string, Texture> caches;
MapRoute map;
// Start is called before the first frame update
private void Awake()
{
caches = new Dictionary<string, Texture>();
UIManager.AddEvent(transform.Find("Main/BtnClose").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
UIManager.AddEvent(transform.Find("Main/Right/BtnClose").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
UIManager.AddEvent(transform.Find("Main/Right/BtnRide").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (map != null)
{
App.RouteIdParam = map.Id;
SceneManager.LoadScene("Ride");
}
});
}
protected override void OnDestroy()
{
caches = null;
Resources.UnloadUnusedAssets();
GC.Collect();
Debug.Log("list empty");
}
public void Initial(MapRoute map)
{
this.map = map;
transform.Find("Main/MapItem-Mobile").GetComponent<MapItem>().Initial(map,caches);
transform.Find("Main/Right/S2").GetComponent<Text>().text = App.GetLocalLanguage() == "zh" ? $"<color=#fff>是否要加入</color><color=#f93086>{map.Name}</color><color=#fff>骑行?</color>" : $"<color=#fff>Join</color> <color=#f93086>{map.Name}</color><color=#fff>?</color>";
}
}