using Assets.Scripts; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ActivityAdController : PFUIPanel { Dictionary caches; protected override void Awake() { caches = new Dictionary(); UIManager.AddEvent(transform.Find("Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => { Close(); if (App.adQueue.Count > 0) { Invoke("ShowSelf", 0.5f); } }); UIManager.AddEvent(transform.Find("Image").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b => { Close(); //可以传参 //UIManager.ShowActivityPanel(url); await ConfigHelper.activityApi.JoinActivity(id); if (string.IsNullOrEmpty(App.CurrentUser.Contact) || string.IsNullOrEmpty(App.CurrentUser.ContactPhone) || string.IsNullOrEmpty(App.CurrentUser.ContactAddress)) { UIManager.ShowAddressPanel(); } else { UIManager.ShowActivityPanel(url); } }); //UIManager.AddEvent(transform.Find("LightUpChina/BtnRule").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => //{ // Application.OpenURL("https://www.baidu.com/"); //}); } private void ShowSelf() { var ad = App.adQueue.Dequeue(); UIManager.ShowActivityAdPanel(ad.Id, ad.DetailUrl, ad.Url + $"?Token={App.CurrentUser.cookie}"); } string image = null, url = null; int id = 0; public void Initial(int id, string image, string url) { this.id = id; this.image = image; var ri = transform.Find("Image").GetComponent(); Utils.DisplayImageTempDict(ri, image, caches); App.ActivityUrl = url; this.url = url; } // Update is called once per frame void Update() { } protected override void OnDestroy() { caches = null; Resources.UnloadUnusedAssets(); GC.Collect(); } }