集合首页和详情页
This commit is contained in:
1 parent
16b42a19e4
commit
ec4a28cd2a
66 files changed
+10600
-818
No files matched your search
@@ -36,6 +36,7 @@ namespace Assets.Scripts.Apis
|
||||
return Post<JsonResult<List<MapRecordRanking>>>("Map/GetCyclingRecordsById", id).data;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过Id获取路书
|
||||
/// </summary>
|
||||
@@ -57,14 +58,14 @@ namespace Assets.Scripts.Apis
|
||||
/// <param name="sort">hot, distance</param>
|
||||
/// <param name="sortDire">asc</param>
|
||||
/// <returns></returns>
|
||||
public Task<JsonResult<List<MapRoute>>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "", bool isFav = false)
|
||||
public Task<JsonResult<List<MapRoute>>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "", bool isFav = false,bool isMine = false,bool isRecent = false)
|
||||
{
|
||||
string lngLat = "";
|
||||
if (sort.Equals("Near"))
|
||||
{
|
||||
lngLat = $"{App.longitude},{App.latitude}";
|
||||
}
|
||||
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }&isFav={isFav}&lngLat={lngLat}";
|
||||
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }&isFav={isFav}&lngLat={lngLat}&isMine={isMine}&isRecent={isRecent}";
|
||||
|
||||
return GetAsync<JsonResult<List<MapRoute>>>(url);
|
||||
}
|
||||
@@ -159,5 +160,17 @@ namespace Assets.Scripts.Apis
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<MapRouteArea>>> GetMapRouteAreaList(int pageIndex, int pageSize)
|
||||
{
|
||||
var result = await GetAsync<JsonResult<List<MapRouteArea>>>($"MapRouteArea/GetList?pageSize={pageSize}&pageIndex={pageIndex}");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<JsonResult<List<MapRoute>>> GetMapRouteAreaDetail(int id, int pageIndex, int pageSize)
|
||||
{
|
||||
var result = await GetAsync<JsonResult<List<MapRoute>>>($"MapRouteArea/GetRouteList?areaId={id}&pageSize={pageSize}&pageIndex={pageIndex}");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class MapRouteArea
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int UserId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int? ParentId { get; set; }
|
||||
/// <summary>
|
||||
/// 环江苏
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CoverImage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<MapRouteAreaItem> areas { get; set; }
|
||||
}
|
||||
|
||||
public class MapRouteAreaItem
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int UserId { get; set; }
|
||||
/// <summary>
|
||||
/// 环南京
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime UpdateTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int TotalNum { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool IsStage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public bool IsDeleted { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CoverImage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string BannerImage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Type { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int? ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9432b85a8cb5174eb3dfd5a1361f96b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,7 +18,7 @@ public delegate void ChangeLanguageDelegate();
|
||||
|
||||
public static class App
|
||||
{
|
||||
public static string Host = "http://192.168.0.101:5087/";
|
||||
public static string Host = "http://192.168.0.101:5085/";
|
||||
|
||||
public static string AppVersion = Application.version;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using Assets.Scripts;
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using Assets.Scripts.Scenes;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using DG.Tweening;
|
||||
using Mapbox.Examples;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -22,6 +23,7 @@ public class MainController : BaseScene
|
||||
Version.text = "V"+App.AppVersion;
|
||||
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
||||
Loom.Initialize();
|
||||
msg = transform.Find("GameObject/Message").GetComponent<CanvasGroup>();
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
transform.GetComponent<CanvasScaler>().referenceResolution = new Vector2(844, 390);
|
||||
//transform.Find("Panel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
|
||||
@@ -138,8 +140,26 @@ public class MainController : BaseScene
|
||||
//Debug.Log("StopScan");
|
||||
}
|
||||
}
|
||||
|
||||
DoMessage();
|
||||
}
|
||||
|
||||
float messageTime = 2;
|
||||
CanvasGroup msg;
|
||||
void DoMessage()
|
||||
{
|
||||
messageTime -= Time.deltaTime;
|
||||
if (messageTime <= 0)
|
||||
{
|
||||
msg.DOFade(1, 0.5f).onComplete = () => Invoke("fade0", 0.8f);
|
||||
messageTime += 2;
|
||||
}
|
||||
}
|
||||
void fade0()
|
||||
{
|
||||
Debug.Log(162 + "执行");
|
||||
msg.DOFade(0, 0.5f);
|
||||
}
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||
|
||||
@@ -230,7 +230,10 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
|
||||
map.IsFavorite = !map.IsFavorite;
|
||||
transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
|
||||
UIManager.Instance.collectDict[map.IsFavorite];
|
||||
this.model.IsFavorite = map.IsFavorite;
|
||||
if (model != null)
|
||||
{
|
||||
this.model.IsFavorite = map.IsFavorite;
|
||||
}
|
||||
//SetColor(map.IsFavorite);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System.Collections;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteGroupController : MonoBehaviour
|
||||
{
|
||||
@@ -15,4 +18,9 @@ public class NewRouteGroupController : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initial(MapRouteArea groupItem)
|
||||
{
|
||||
transform.Find("Title").GetComponent<Text>().text = groupItem.Name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteItemController : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Initial(MapRouteAreaItem area, Dictionary<string, Texture> caches = null)
|
||||
{
|
||||
if (area.CoverImage != null)
|
||||
{
|
||||
Utils.DisplayImageTempDict(GetComponent<RawImage>(), area.CoverImage, caches);
|
||||
}
|
||||
transform.Find("Panel/Text").GetComponent<Text>().text = area.Name;
|
||||
UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowNewRouteDetailPanel(area);
|
||||
//ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id, 0, 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ede6683b9fc33934aae08dee1363e667
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -103,7 +103,7 @@ public class HomeController : PFUIPanel
|
||||
Debug.Log(App.firstEnter.ToString());
|
||||
//UIManager.ShowEarthPanel(App.latitude, App.longitude);
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
UIManager.ShowMapListPanel();
|
||||
UIManager.ShowNewRouteOverviewPanel();
|
||||
#else
|
||||
if (App.firstEnter == 0)
|
||||
{
|
||||
|
||||
@@ -92,8 +92,8 @@ public class MapListController : PFUIPanel
|
||||
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem-Mobile");
|
||||
#else
|
||||
topContainer = transform.Find("Panel").Find("Top");
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
#endif
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
sort = "Near";
|
||||
sortDire = "asc";
|
||||
//if (hardSelector != null)
|
||||
@@ -159,7 +159,7 @@ public class MapListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
BindHeadImage();
|
||||
GetList();
|
||||
Refresh();
|
||||
if (scroll != null)
|
||||
{
|
||||
//scroll.GetComponent<ScrollRect>().onValueChanged.AddListener((v) =>
|
||||
@@ -330,14 +330,14 @@ public class MapListController : PFUIPanel
|
||||
string ftname = "";
|
||||
string distance = "";
|
||||
List<string> hands = new List<string>();
|
||||
bool is3d = false,isFav = false;
|
||||
bool is3d = false,isFav = false,isMine = false,isRecent = false;
|
||||
string sort = "",sortDire = "";
|
||||
//string name = "";
|
||||
//string name = "";
|
||||
async void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
|
||||
var res = await ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav,isMine,isRecent);
|
||||
if (res.result)
|
||||
{
|
||||
if (res.data.Count == 0)
|
||||
@@ -380,6 +380,7 @@ public class MapListController : PFUIPanel
|
||||
public void Refresh()
|
||||
{
|
||||
content.transform.DestroyChildren();
|
||||
HandleType();
|
||||
pageIndex = 0;
|
||||
isEnd = false;
|
||||
GetList();
|
||||
@@ -389,8 +390,10 @@ public class MapListController : PFUIPanel
|
||||
{
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
var routeTypeName = transform.Find("Panel/Top/RouteTypeName");
|
||||
routeTypeName.GetComponent<Text>().text = App.GetLocalString(App.CurrentRouteType);
|
||||
#else
|
||||
var routeTypeName = transform.Find("Panel/RouteTypeName");
|
||||
#endif
|
||||
routeTypeName.GetComponent<Text>().text = App.GetLocalString(App.CurrentRouteType);
|
||||
if (searchInput != null)
|
||||
{
|
||||
//empty Data
|
||||
@@ -429,10 +432,28 @@ public class MapListController : PFUIPanel
|
||||
var drop = sorts.GetComponent<Dropdown>();
|
||||
drop.value = 0;
|
||||
}
|
||||
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
void HandleType()
|
||||
{
|
||||
isRecent = false;
|
||||
isFav = false;
|
||||
isMine = false;
|
||||
if (App.CurrentRouteType == "My Upload")
|
||||
{
|
||||
isMine = true;
|
||||
}
|
||||
else if (App.CurrentRouteType == "My Collection")
|
||||
{
|
||||
isFav = true;
|
||||
}
|
||||
else if (App.CurrentRouteType == "Recent Routes")
|
||||
{
|
||||
isRecent = true;
|
||||
}
|
||||
}
|
||||
void ResetList()
|
||||
{
|
||||
distance = "";
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteDetailController : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Dictionary<string, Texture> caches;
|
||||
GameObject map;
|
||||
ScrollRect scroll;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
caches = new Dictionary<string, Texture>();
|
||||
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
|
||||
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem-Mobile");
|
||||
#else
|
||||
map = Resources.Load<GameObject>("UI/Prefab/MapList/MapItem");
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
transform.Find("MainNav").GetComponent<MainNav>().ShowBack();
|
||||
var rect = transform.GetComponent<RectTransform>();
|
||||
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
|
||||
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
if (scroll.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
MapRouteAreaItem area;
|
||||
int pageIndex = 0, pageSize = 10;
|
||||
bool isEnd = false, startMouse = false;
|
||||
public async void Initial(MapRouteAreaItem area)
|
||||
{
|
||||
isEnd = false;
|
||||
pageIndex = 0;
|
||||
this.area = area;
|
||||
var left = transform.Find("Container/Left");
|
||||
left.Find("Icon").GetComponent<RawImage>().texture = null;
|
||||
scroll.content.DestroyChildren();
|
||||
if (area.BannerImage != null)
|
||||
{
|
||||
Utils.DisplayImageTempDict(left.Find("Icon").GetComponent<RawImage>(), area.BannerImage, caches);
|
||||
}
|
||||
left.Find("Name").GetComponent<Text>().text = area.Name;
|
||||
GetList();
|
||||
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
Debug.Log(scroll.verticalNormalizedPosition);
|
||||
if (scroll.verticalNormalizedPosition <= 0 && !isEnd)
|
||||
{
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
}
|
||||
|
||||
private async void GetList()
|
||||
{
|
||||
var res = await ConfigHelper.mapApi.GetMapRouteAreaDetail(area.Id, pageIndex, pageSize);
|
||||
if (res.result)
|
||||
{
|
||||
if (res.data.Count > 0)
|
||||
{
|
||||
DisplayMaps(res.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayMaps(List<MapRoute> list)
|
||||
{
|
||||
if (map != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(map);
|
||||
obj.GetComponent<MapItem>().Initial(item, caches);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.SetParent(scroll.content.transform);
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f7db27f83919ce49a865d9187ff71aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +1,10 @@
|
||||
using Assets.Scripts;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewRouteOverviewController: PFUIPanel
|
||||
@@ -9,25 +12,54 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
// Start is called before the first frame update
|
||||
Transform tmpGroup;
|
||||
Transform tmpItem;
|
||||
int bannerIndex = 0;
|
||||
float? startPos = null;
|
||||
RectTransform bannerContent,collectionContent;
|
||||
Dictionary<string, Texture> caches = null;
|
||||
ScrollRect scroll;
|
||||
protected override void Awake()
|
||||
{
|
||||
caches = new Dictionary<string, Texture>();
|
||||
scroll = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>();
|
||||
UIManager.AddEvent(scroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
if (scroll.verticalNormalizedPosition <= 0 && !isEnd)
|
||||
{
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
if (scroll.verticalNormalizedPosition >= 1.1)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
tmpGroup = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteGroup");
|
||||
tmpItem = Resources.Load<Transform>("UI/Prefab/NewRoute/RouteItem");
|
||||
var rect = transform.Find("Container/Right/Scroll View/Viewport/Content")
|
||||
#else
|
||||
var rect = transform.GetComponent<RectTransform>();
|
||||
rect.offsetMax = new Vector2(rect.offsetMax.x, 0);
|
||||
rect.offsetMin = new Vector2(rect.offsetMin.x, 0);
|
||||
tmpGroup = Resources.Load<Transform>("UI/Prefab/NewRoute/Mobile/RouteGroup");
|
||||
tmpItem = Resources.Load<Transform>("UI/Prefab/NewRoute/Mobile/RouteItem");
|
||||
#endif
|
||||
collectionContent = transform.Find("Container/Right/Scroll View/Viewport/Content")
|
||||
.GetComponent<RectTransform>();
|
||||
Refresh();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var group = Instantiate<Transform>(tmpGroup);
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
var item = Instantiate<Transform>(tmpItem);
|
||||
item.SetParent(group.Find("Content"));
|
||||
}
|
||||
group.SetParent(rect);
|
||||
group.localScale = Vector3.one;
|
||||
}
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rect);
|
||||
|
||||
var left = transform.Find("Container/Left");
|
||||
UIManager.AddEvent(left.Find("MyUpload").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
@@ -46,8 +78,94 @@ 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
|
||||
}
|
||||
int pageIndex = 0, pageSize = 10;
|
||||
bool isEnd = false,isLock = false;
|
||||
private void Refresh()
|
||||
{
|
||||
pageIndex = 0;
|
||||
isEnd = false;
|
||||
scroll.content.DestroyChildren();
|
||||
GetList();
|
||||
}
|
||||
|
||||
async void GetList()
|
||||
{
|
||||
if (isLock) return;
|
||||
isLock = true;
|
||||
var res = await ConfigHelper.mapApi.GetMapRouteAreaList(pageIndex, pageSize);
|
||||
isLock = false;
|
||||
if (!res.result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (res.data.Count == 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
foreach (var groupItem in res.data)
|
||||
{
|
||||
var group = Instantiate<Transform>(tmpGroup);
|
||||
group.GetComponent<NewRouteGroupController>().Initial(groupItem);
|
||||
foreach (var area in groupItem.areas)
|
||||
{
|
||||
var item = Instantiate<Transform>(tmpItem);
|
||||
item.GetComponent<NewRouteItemController>().Initial(area, caches);
|
||||
item.SetParent(group.Find("Content"));
|
||||
}
|
||||
group.SetParent(collectionContent);
|
||||
group.localScale = Vector3.one;
|
||||
}
|
||||
//for (int i = 0; i < 10; i++)
|
||||
//{
|
||||
// var group = Instantiate<Transform>(tmpGroup);
|
||||
// for (int j = 0; j < 10; j++)
|
||||
// {
|
||||
// var item = Instantiate<Transform>(tmpItem);
|
||||
// item.SetParent(group.Find("Content"));
|
||||
// }
|
||||
// group.SetParent(collectionContent);
|
||||
// group.localScale = Vector3.one;
|
||||
//}
|
||||
//获取数据后需要重绘
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(collectionContent);
|
||||
}
|
||||
void MoveBanner(bool right)
|
||||
{
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
if (bannerContent == null) return;
|
||||
if (!startPos.HasValue)
|
||||
{
|
||||
startPos = bannerContent.localPosition.x;
|
||||
Debug.Log(startPos);
|
||||
}
|
||||
var k = right ? -1 : 1;
|
||||
bannerIndex += k;
|
||||
if (bannerIndex > 0)
|
||||
{
|
||||
bannerIndex = -3;
|
||||
}
|
||||
else if (bannerIndex < -3)
|
||||
{
|
||||
bannerIndex = 0;
|
||||
}
|
||||
bannerContent.DOLocalMoveX(startPos.Value + bannerIndex * 1171, 0.5f);
|
||||
#endif
|
||||
}
|
||||
void ToList(string type)
|
||||
{
|
||||
App.CurrentRouteType = type;// "";
|
||||
@@ -60,8 +178,31 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
transform.MyDOFade();
|
||||
}
|
||||
// Update is called once per frame
|
||||
float time = 10;
|
||||
bool startMouse = false;
|
||||
void Update()
|
||||
{
|
||||
|
||||
time -= Time.deltaTime;
|
||||
if (time <= 0)
|
||||
{
|
||||
MoveBanner(true);
|
||||
time += 10;
|
||||
}
|
||||
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
if (scroll.verticalNormalizedPosition <= 0 || scroll.verticalNormalizedPosition>=1.1)
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -323,6 +323,21 @@ public class UIManager : MonoBehaviour
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.NewRouteOverviewPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
private NewRouteDetailController mNewRouteDetailController;
|
||||
public NewRouteDetailController NewRouteDetailPanel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetPanelInstance("NewRouteDetailPanel", ref this.mNewRouteDetailController);
|
||||
}
|
||||
}
|
||||
public static void ShowNewRouteDetailPanel(MapRouteAreaItem area)
|
||||
{
|
||||
UIManager.Instance.NewRouteDetailPanel
|
||||
.GetComponent<NewRouteDetailController>().Initial(area);
|
||||
UIManager.Show(UIManager.Instance.NewRouteDetailPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
#endregion
|
||||
private CountDownAnimation mCountDownAnimation;
|
||||
public CountDownAnimation CountDownAnimation
|
||||
|
||||
@@ -290,14 +290,13 @@ namespace Assets.Scripts
|
||||
}
|
||||
}
|
||||
/*删除父亲节点下的所有孩子*/
|
||||
static public void DestroyChildren(this Transform t)
|
||||
static public void DestroyChildren(this Transform t,string igNoreName = null)
|
||||
{
|
||||
bool isPlaying = Application.isPlaying;
|
||||
|
||||
while (t.childCount != 0)
|
||||
{
|
||||
Transform child = t.GetChild(0);
|
||||
|
||||
if (isPlaying)
|
||||
{
|
||||
child.SetParent(null);
|
||||
|
||||
Reference in new issue
Block a user