两个列表进骑行释放内存
This commit is contained in:
1 parent
3295314b7e
commit
6a4390f1b9
7 files changed
+88
-32
No files matched your search
@@ -40,6 +40,10 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
}
|
||||
public void Initial(MapCompetition mapCompetition,Transform parent,string from = "list")
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
transform.GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
@@ -48,7 +52,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
App.CompetionId = mapCompetition.Id;
|
||||
SceneManager.LoadScene("Ride");
|
||||
});
|
||||
Utils.DisplayImage(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, true);
|
||||
Utils.DisplayImageTempDict(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, this.parent.GetComponent<RaceScript>().caches);
|
||||
#else
|
||||
if (string.IsNullOrEmpty(_from))
|
||||
{
|
||||
@@ -56,14 +60,14 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
}
|
||||
if (_from == "list")
|
||||
{
|
||||
Utils.DisplayImage(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, true);
|
||||
Utils.DisplayImageTempDict(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, this.parent.GetComponent<RaceScript>().caches);
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.ShowRaceDetailModal(transform,mapCompetition);
|
||||
});
|
||||
}
|
||||
#endif
|
||||
Utils.DisplayImage(transform.Find("AltitudeCurve").GetComponent<RawImage>(), mapCompetition.AltitudeGraph, true);
|
||||
Utils.DisplayImageTempDict(transform.Find("AltitudeCurve").GetComponent<RawImage>(), mapCompetition.AltitudeGraph, this.parent.GetComponent<RaceScript>().caches);
|
||||
transform.Find("InfoContainer/Text").GetComponent<Text>().SetTextWithEllipsis(mapCompetition.Title);
|
||||
transform.Find("GetReadyContainer").gameObject.SetActive(mapCompetition.Status != 4);
|
||||
transform.Find("GetReadyContainer-2").gameObject.SetActive(mapCompetition.Status == 1);
|
||||
@@ -91,10 +95,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
|
||||
SetButtonGroup(mapCompetition);
|
||||
}
|
||||
#endif
|
||||
if (parent != null)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
this.mapCompetition = mapCompetition;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Assets.Scripts;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -10,6 +11,8 @@ public class RaceScript : PFUIPanel
|
||||
// Start is called before the first frame update
|
||||
protected Transform currentItem { get; set; }
|
||||
IEnumerator _timer { get; set; }
|
||||
public Dictionary<string, Texture> caches { get; set; }
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
@@ -71,7 +74,6 @@ public class RaceScript : PFUIPanel
|
||||
while (true)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f); //
|
||||
Debug.Log(123);
|
||||
HandleTime();
|
||||
//time = UIManager.Now.GetDateTime().AddSeconds(1);
|
||||
}
|
||||
@@ -138,8 +140,10 @@ public class RaceScript : PFUIPanel
|
||||
}
|
||||
}
|
||||
|
||||
void Awake()
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
caches = new Dictionary<string, Texture>();
|
||||
if (_timer == null)
|
||||
{
|
||||
_timer = Timer();
|
||||
@@ -151,4 +155,12 @@ public class RaceScript : PFUIPanel
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user