加入合集后的跳转问题

This commit is contained in:
Caiyanpeng committed 2021-12-15 11:08:25 +08:00
1 parent ec4a28cd2a
commit 6ed3895fcd
13 files changed
+292 -534

No files matched your search

+15 -18
View File
@@ -44,12 +44,14 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
float? localY = null;
MapRoute map;
Dictionary<string, Texture> caches;
public void Initial(MapRoute myMap, Dictionary<string, Texture> caches)
private MapRouteAreaItem area = null;
public void Initial(MapRoute myMap, Dictionary<string, Texture> caches, MapRouteAreaItem area = null)
{
if (caches != null)
{
this.caches = caches;
}
this.area = area;
map = myMap;
//localY = transform.GetComponent<RectTransform>().rect.height;
//Debug.Log(localY);
@@ -87,20 +89,7 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
// SceneManager.LoadScene("Ride");
//});
transform.GetComponent<Button>().onClick.RemoveAllListeners();
transform.GetComponent<Button>().onClick.AddListener(() =>
{
//UIManager.ShowMapDetailPanel(myMap.Id);
App.RouteIdParam = myMap.Id;
if (!App.MainSceneParam.ContainsKey("Name"))
{
App.MainSceneParam.Add("Name", "MapListPanel");
}
else
{
App.MainSceneParam["Name"] = "MapListPanel";
}
SceneManager.LoadScene("Ride");
});
transform.GetComponent<Button>().onClick.AddListener(Ride);
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
transform.Find("IdContainer/Text").GetComponent<Text>().text = $"#{myMap.Id}";
@@ -136,13 +125,21 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
private void Ride()
{
App.RouteIdParam = map.Id;
if (!App.MainSceneParam.ContainsKey("Name"))
App.currentArea = area;
if (area != null)
{
App.MainSceneParam.Add("Name", "MapListPanel");
App.MainSceneParam["Name"] = "NewRouteDetail";
}
else
{
App.MainSceneParam["Name"] = "MapListPanel";
if (!App.MainSceneParam.ContainsKey("Name"))
{
App.MainSceneParam.Add("Name", "MapListPanel");
}
else
{
App.MainSceneParam["Name"] = "MapListPanel";
}
}
SceneManager.LoadScene("Ride");
//foreach (var item in Utils.propTextureCache)
@@ -27,10 +27,10 @@ public class NewRouteItemController : MonoBehaviour
Utils.DisplayImageTempDict(GetComponent<RawImage>(), area.CoverImage, caches);
}
transform.Find("Panel/Text").GetComponent<Text>().text = area.Name;
UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
GetComponent<Button>().onClick.RemoveAllListeners();
GetComponent<Button>().onClick.AddListener(() =>
{
UIManager.ShowNewRouteDetailPanel(area);
//ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id, 0, 10);
});
}
}
@@ -46,14 +46,20 @@ public class MapListController : PFUIPanel
}
private bool isEnd = false;
private Transform topContainer;
void ResetPage()
{
var rect = transform.GetComponent<RectTransform>();
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
rect.localScale = Vector3.one;
rect.localPosition = Vector3.zero;
}
protected override void Start()
{
#if (UNITY_ANDROID || UNITY_IOS)
topContainer = transform.Find("Top");
var rect = transform.GetComponent<RectTransform>();
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
ResetPage();
//var rectTransform = transform.GetComponent<RectTransform>();
//var offsetMax = rectTransform.offsetMax;
//rectTransform.offsetMax = new Vector2(0, offsetMax.y);
@@ -499,6 +505,9 @@ public class MapListController : PFUIPanel
{
transform.Find("RawImage").GetComponent<RawImage>().texture = App.DefaultRotateTexture;
}
#if UNITY_ANDROID || UNITY_IOS
ResetPage();
#endif
ResetPanel();
transform.MyDOFade();
}
@@ -71,11 +71,20 @@ public class NewRouteDetailController : PFUIPanel
var left = transform.Find("Container/Left");
left.Find("Icon").GetComponent<RawImage>().texture = null;
scroll.content.DestroyChildren();
transform.Find("Container/Left/RideContainer/Text").GetComponent<Text>()
.text = string.Empty;
transform.Find("Container/Left/Infos/DistanceContainer/Text").GetComponent<Text>()
.text = string.Empty;
transform.Find("Container/Left/Infos/EleContainer/Text").GetComponent<Text>()
.text = string.Empty;
transform.Find("Container/Left/Infos/SlopeContainer/Text").GetComponent<Text>()
.text = string.Empty;
if (area.BannerImage != null)
{
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.BannerImage, caches);
}
left.Find("Name").GetComponent<Text>().text = area.Name;
GetData();
GetList();
}
@@ -89,10 +98,26 @@ public class NewRouteDetailController : PFUIPanel
GetList();
}
}
private async void GetData()
{
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id);
if (res.result)
{
transform.Find("Container/Left/RideContainer/Text").GetComponent<Text>()
.text = res.data.RideCount.ToString();
transform.Find("Container/Left/Infos/DistanceContainer/Text").GetComponent<Text>()
.text = $"{res.data.TotalDistance.ToString("#0")}KM";
transform.Find("Container/Left/Infos/EleContainer/Text").GetComponent<Text>()
.text = $"{res.data.TotalClimb.ToString("#0")}M";
transform.Find("Container/Left/Infos/SlopeContainer/Text").GetComponent<Text>()
.text = $"{res.data.AverageGrade.ToString("#0.00")}%";
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.Find("Container/Left/RideContainer").GetComponent<RectTransform>());
}
}
private async void GetList()
{
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id, pageIndex, pageSize);
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetailList(area.Id, pageIndex, pageSize);
if (res.result)
{
if (res.data.Count > 0)
@@ -113,7 +138,7 @@ public class NewRouteDetailController : PFUIPanel
foreach (var item in list)
{
var obj = Instantiate(map);
obj.GetComponent<MapItem>().Initial(item, caches);
obj.GetComponent<MapItem>().Initial(item, caches, area);
//obj.SendMessage("Initial", );
obj.transform.SetParent(scroll.content.transform);
obj.transform.localScale = new Vector3(1, 1, 1);
@@ -78,20 +78,21 @@ public class NewRouteOverviewController: PFUIPanel
{
ToList("All Route");
});
#if !(UNITY_ANDROID || UNITY_IOS)
var banner = collectionContent.Find("Banner");
bannerContent = banner.Find("Viewport/Content").GetComponent<RectTransform>();
var btnLeft = banner.Find("Left");
var btnRight = banner.Find("Right");
UIManager.AddEvent(btnLeft.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
MoveBanner(false);
});
UIManager.AddEvent(btnRight.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
MoveBanner(true);
});
#endif
//banner暂时注释
//#if !(UNITY_ANDROID || UNITY_IOS)
// var banner = collectionContent.Find("Banner");
// bannerContent = banner.Find("Viewport/Content").GetComponent<RectTransform>();
// var btnLeft = banner.Find("Left");
// var btnRight = banner.Find("Right");
// UIManager.AddEvent(btnLeft.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
// {
// MoveBanner(false);
// });
// UIManager.AddEvent(btnRight.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
// {
// MoveBanner(true);
// });
//#endif
}
int pageIndex = 0, pageSize = 10;
bool isEnd = false,isLock = false;