PlacesItem.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using Excel2Json;
  3. using Fort23.UTool;
  4. using UnityEngine;
  5. namespace Fort23.Mono
  6. {
  7. public class PlacesItem
  8. {
  9. public GameObjectPool gameObjectPool;
  10. public BigMapConfig bigMapConfig;
  11. private ReferenceCollector referenceCollector;
  12. public async void CustomInit(int bigMapId, GameObjectPool gameObjectPool, Action<ItemWidgetBasic> callBack = null)
  13. {
  14. this.gameObjectPool = gameObjectPool;
  15. bigMapConfig = ConfigComponent.Instance.Get<BigMapConfig>(bigMapId);
  16. referenceCollector = gameObjectPool.own.GetComponent<ReferenceCollector>();
  17. for (var i = 0; i < bigMapConfig.places.Length; i++)
  18. {
  19. GameObject gam = referenceCollector.Get<GameObject>("places_" + bigMapConfig.places[i]);
  20. PlacesWidget placesWidget = await UIManager.Instance.CreateGComponentForObject<PlacesWidget>(gam, null);
  21. placesWidget.OnClick = callBack;
  22. placesWidget.CustomInit(bigMapConfig.places[i]);
  23. }
  24. }
  25. public void Dispose()
  26. {
  27. UIManager.Instance.DormancyGComponent(gameObjectPool);
  28. gameObjectPool = null;
  29. referenceCollector = null;
  30. }
  31. }
  32. }