banner bug;maxranking修改

This commit is contained in:
CaiYanPeng 2022-01-12 10:29:10 +08:00
parent 939774bd42
commit f0df68bbda
3 changed files with 18 additions and 8 deletions

View File

@ -15,6 +15,7 @@ public class BannerController : MonoBehaviour
private List<Vector3> standardPositions; private List<Vector3> standardPositions;
private List<Recommand> list; private List<Recommand> list;
private int currentIndex = 1; private int currentIndex = 1;
private Dictionary<string, Texture> caches;
void Awake() void Awake()
{ {
itemList = new List<CanvasGroup> itemList = new List<CanvasGroup>
@ -23,6 +24,7 @@ public class BannerController : MonoBehaviour
transform.Find("2").GetComponent<CanvasGroup>(), transform.Find("2").GetComponent<CanvasGroup>(),
transform.Find("3").GetComponent<CanvasGroup>() transform.Find("3").GetComponent<CanvasGroup>()
}; };
caches = new Dictionary<string, Texture>();
standardPositions = new List<Vector3> standardPositions = new List<Vector3>
{ {
transform.Find("1").localPosition,transform.Find("2").localPosition,transform.Find("3").localPosition transform.Find("1").localPosition,transform.Find("2").localPosition,transform.Find("3").localPosition
@ -130,7 +132,7 @@ public class BannerController : MonoBehaviour
{ {
var area = list[index++]; var area = list[index++];
c.GetComponent<RecommendController>().Initial(area); c.GetComponent<RecommendController>().Initial(area, caches);
c.GetComponent<Button>().onClick.RemoveAllListeners(); c.GetComponent<Button>().onClick.RemoveAllListeners();
if (c.alpha != 1) if (c.alpha != 1)
{ {
@ -151,12 +153,14 @@ public class BannerController : MonoBehaviour
currentIndex = 1; currentIndex = 1;
this.list = list; this.list = list;
} }
bool animateLock = false;
private void Right() private void Right()
{ {
int center = GetCenterIndex(), int center = GetCenterIndex(),
left = GetSideIndex(true), left = GetSideIndex(true),
right = GetSideIndex(false); right = GetSideIndex(false);
if (center == -1 || left == -1 || right == -1) return; if (center == -1 || left == -1 || right == -1 || animateLock) return;
animateLock = true;
DOTween.CompleteAll(); DOTween.CompleteAll();
DORight(itemList[left], itemList[center], itemList[right]); DORight(itemList[left], itemList[center], itemList[right]);
} }
@ -168,12 +172,12 @@ public class BannerController : MonoBehaviour
se.Join(center.GetComponent<RectTransform>().DOLocalMoveX(43, 0.3f)); se.Join(center.GetComponent<RectTransform>().DOLocalMoveX(43, 0.3f));
se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(-43, 0.3f)); se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(-43, 0.3f));
var area = list[((currentIndex++) + list.Count) % list.Count]; var area = list[((currentIndex++) + list.Count) % list.Count];
right.GetComponent<RecommendController>().Initial(area); right.GetComponent<RecommendController>().Initial(area, caches);
if (currentIndex >= list.Count) currentIndex = 0; if (currentIndex >= list.Count) currentIndex = 0;
se.Join(left.DOFade(1, 0.3f)); se.Join(left.DOFade(1, 0.3f));
se.Join(left.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f)); se.Join(left.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f));
se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f)); se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f));
se.Play(); se.Play().onComplete = ()=> { animateLock = false; };
left.transform.SetAsLastSibling(); left.transform.SetAsLastSibling();
//事件改变 //事件改变
left.GetComponent<Button>().onClick.RemoveAllListeners(); left.GetComponent<Button>().onClick.RemoveAllListeners();
@ -189,7 +193,8 @@ public class BannerController : MonoBehaviour
int center = GetCenterIndex(), int center = GetCenterIndex(),
left = GetSideIndex(true), left = GetSideIndex(true),
right = GetSideIndex(false); right = GetSideIndex(false);
if (center == -1 || left == -1 || right == -1) return; if (center == -1 || left == -1 || right == -1|| animateLock) return;
animateLock = true;
DOTween.CompleteAll(); DOTween.CompleteAll();
DOLeft(itemList[left], itemList[center], itemList[right]); DOLeft(itemList[left], itemList[center], itemList[right]);
} }
@ -202,12 +207,12 @@ public class BannerController : MonoBehaviour
se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(43, 0.3f)); se.Join(left.GetComponent<RectTransform>().DOLocalMoveX(43, 0.3f));
var area = list[((currentIndex--) + list.Count) % list.Count]; var area = list[((currentIndex--) + list.Count) % list.Count];
var centerArea = list[currentIndex + 1]; var centerArea = list[currentIndex + 1];
left.GetComponent<RecommendController>().Initial(area); left.GetComponent<RecommendController>().Initial(area, caches);
if (currentIndex < 0) currentIndex = list.Count - 1; if (currentIndex < 0) currentIndex = list.Count - 1;
se.Join(right.DOFade(1, 0.3f)); se.Join(right.DOFade(1, 0.3f));
se.Join(right.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f)); se.Join(right.GetComponent<RectTransform>().DOScale(Vector3.one, 0.3f));
se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f)); se.Join(right.GetComponent<RectTransform>().DOLocalMoveX(0, 0.3f));
se.Play(); se.Play().onComplete = () => { animateLock = false; };
right.transform.SetAsLastSibling(); right.transform.SetAsLastSibling();
//事件改变 //事件改变
right.GetComponent<Button>().onClick.RemoveAllListeners(); right.GetComponent<Button>().onClick.RemoveAllListeners();
@ -254,5 +259,8 @@ public class BannerController : MonoBehaviour
{ {
Debug.Log(248+"毁灭"); Debug.Log(248+"毁灭");
TouchKit.removeGestureRecognizer(pan); TouchKit.removeGestureRecognizer(pan);
caches = null;
Resources.UnloadUnusedAssets();
GC.Collect();
} }
} }

View File

@ -185,6 +185,8 @@ public class MainController : BaseScene
#endif #endif
private void DoMessage6(LinkedMessageEvent e) private void DoMessage6(LinkedMessageEvent e)
{ {
//Resources.UnloadUnusedAssets();
//GC.Collect();
var selectIndex = msgIndex % 5; var selectIndex = msgIndex % 5;
var m = msgs[selectIndex]; var m = msgs[selectIndex];
if (msgIndex >= 5) // if (msgIndex >= 5) //

View File

@ -317,7 +317,7 @@ public class HomeController : PFUIPanel
if (res.result) if (res.result)
{ {
maxList = res.data; maxList = res.data;
if (maxList.Count >= 3) if (maxList.Count > 0)
{ {
maxdataTime = 3; maxdataTime = 3;
maxdataIndex = 0; maxdataIndex = 0;