修正地球自适应问题。修正地图搜索卡死问题。
This commit is contained in:
1 parent
c8111d7db3
commit
3b63dec2e1
16 files changed
+725
-1163
No files matched your search
@@ -1,20 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class MapBoxApi: ApiBase
|
||||
{
|
||||
public string GetAddressInfo(string address)
|
||||
public async Task<string> GetAddressInfo(string address)
|
||||
{
|
||||
var url = $"https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/{ address }.json?access_token={ App.MapBoxAccessToken }";
|
||||
var res = Get(url);
|
||||
var url = $"https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/{ UnityWebRequest.EscapeURL(address) }.json?access_token={ App.MapBoxAccessToken }";
|
||||
//var res = Get(url);
|
||||
|
||||
//return System.Text.Encoding.UTF8.GetString(res);
|
||||
return res;
|
||||
var result = await new HttpClient().GetAsync(url);
|
||||
return await result.Content.ReadAsStringAsync();
|
||||
//UnityWebRequest.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace Assets.Scripts.Apis
|
||||
user.LastUpdateFtpTime = ret.data.LastUpdateFtpTime;
|
||||
user.LastUpdateWeightTime = ret.data.LastUpdateWeightTime;
|
||||
user.LastUpdateBicycleWeightTime = ret.data.LastUpdateBicycleWeightTime;
|
||||
user.Height = ret.data.Height;
|
||||
//todo: check local database, insert new user
|
||||
|
||||
//PubCommData.CurrentUser = user;
|
||||
|
||||
@@ -3,12 +3,12 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LoadingPf : MonoBehaviour
|
||||
public class LoadingPf : PFUIPanel
|
||||
{
|
||||
List<Sprite> sprites;
|
||||
Image image;
|
||||
|
||||
private void Start()
|
||||
protected override void Start()
|
||||
{
|
||||
sprites = new List<Sprite>();
|
||||
for (int i = 1; i < 80; i++)
|
||||
@@ -19,11 +19,14 @@ public class LoadingPf : MonoBehaviour
|
||||
}
|
||||
int index = 0;
|
||||
float time = 0;
|
||||
public void Initial()
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
|
||||
index = 0;
|
||||
time = 0;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
|
||||
@@ -99,7 +99,16 @@ public class BigMapController : PFUIPanel
|
||||
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
|
||||
var input = panel.Find("InputField");
|
||||
base.SetRounded(input, 20f);
|
||||
input.GetComponent<InputField>().onEndEdit.AddListener((text) =>
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
this.Search(null);
|
||||
}
|
||||
});
|
||||
|
||||
keyword = input.Find("Text").GetComponent<Text>();
|
||||
|
||||
var searchBtn = input.Find("Search").gameObject;
|
||||
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
|
||||
|
||||
@@ -141,22 +150,27 @@ public class BigMapController : PFUIPanel
|
||||
|
||||
}
|
||||
|
||||
private void Search(BaseEventData e)
|
||||
private async void Search(BaseEventData e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(keyword.text))
|
||||
{
|
||||
//yield return null;
|
||||
return;
|
||||
}
|
||||
Debug.Log(keyword.text);
|
||||
//UIManager.ShowLoadingDialogBox();
|
||||
//Utils.showLoading(this.gameObject);
|
||||
|
||||
var infoStr = mapboxApi.GetAddressInfo(keyword.text);
|
||||
//Debug.Log(info);
|
||||
UIManager.ShowLoadingDialogBox();
|
||||
|
||||
var infoStr = await mapboxApi.GetAddressInfo(keyword.text);
|
||||
//Debug.Log(infoStr);
|
||||
var info = Newtonsoft.Json.Linq.JObject.Parse(infoStr);
|
||||
|
||||
var center = (info["features"] as JArray).First()["center"];
|
||||
mapManager.UpdateMap(new Vector2d(Convert.ToDouble(center[1]), Convert.ToDouble(center[0])));
|
||||
//mapManager.SetCenterLatitudeLongitude(new Vector2d(31.325053, 120.623564));
|
||||
//mapManager.UpdateMap(new Vector2d(31.325053, 120.623564));
|
||||
|
||||
|
||||
UIManager.HideLoadingDialogBox();
|
||||
}
|
||||
|
||||
private void MapManager_OnInitialized()
|
||||
|
||||
@@ -22,11 +22,21 @@ public class EarthController : PFUIPanel
|
||||
private GameObject hotPanel;
|
||||
private GameObject content;
|
||||
private Object itemObject;
|
||||
Transform rootPanel;
|
||||
Canvas canvas;
|
||||
float time = 0f;
|
||||
bool showSummary = false;
|
||||
Vector2 latlonCenter;
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
mapApi = new MapApi();
|
||||
|
||||
canvas = this.transform.Find("Canvas").GetComponent<Canvas>();
|
||||
canvas.worldCamera = Camera.main;
|
||||
|
||||
rootPanel = this.transform.Find("Canvas").Find("Panel");
|
||||
|
||||
map = WorldMapGlobe.instance;
|
||||
map.showProvinces = true;
|
||||
map.showCities = true;
|
||||
@@ -46,7 +56,7 @@ public class EarthController : PFUIPanel
|
||||
protected override void Start()
|
||||
{
|
||||
itemObject = Resources.Load("UI/Prefab/BigMap/Item");
|
||||
var rootPanel = this.transform.Find("Canvas").Find("Panel");
|
||||
|
||||
var panel = rootPanel.Find("Panel");
|
||||
|
||||
SetRounded(panel, 60);
|
||||
@@ -111,11 +121,14 @@ public class EarthController : PFUIPanel
|
||||
|
||||
Province.text = province.name;
|
||||
|
||||
ShowSummary(province.latlonCenter);
|
||||
latlonCenter = province.latlonCenter;
|
||||
time = 0f;
|
||||
showSummary = true;
|
||||
//ShowSummary(province.latlonCenter);
|
||||
};
|
||||
map.OnProvinceExit += (int provinceIndex, int regionIndex) =>
|
||||
{
|
||||
|
||||
showSummary = false;
|
||||
};
|
||||
map.OnProvinceClick += (int provinceIndex, int regionIndex) =>
|
||||
{
|
||||
@@ -188,7 +201,7 @@ public class EarthController : PFUIPanel
|
||||
|
||||
private void Map_OnClick(Vector3 sphereLocation, int mouseButtonIndex)
|
||||
{
|
||||
Debug.Log("click");
|
||||
//Debug.Log("click");
|
||||
|
||||
Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation);
|
||||
Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y);
|
||||
@@ -211,8 +224,18 @@ public class EarthController : PFUIPanel
|
||||
void Update()
|
||||
{
|
||||
//var zoom = map.GetZoomLevel();
|
||||
|
||||
//Debug.Log(zoom);
|
||||
|
||||
if (showSummary)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
if (time >= 0.2)
|
||||
{
|
||||
ShowSummary(latlonCenter);
|
||||
showSummary = false;
|
||||
}
|
||||
}
|
||||
//Debug.Log(showSummary + "," + time);
|
||||
}
|
||||
|
||||
public void Show(double lat, double lon)
|
||||
|
||||
@@ -191,7 +191,7 @@ public class UIManager : MonoBehaviour
|
||||
{
|
||||
if (internalComponent == null)
|
||||
{
|
||||
UnityEngine.Object @object = Resources.Load("UI/Prefab/" + prefabName);
|
||||
UnityEngine.Object @object = Resources.Load("UI/Prefab/Common/" + prefabName);
|
||||
if (@object != null)
|
||||
{
|
||||
GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(@object, base.transform.parent, false);
|
||||
@@ -353,6 +353,44 @@ public class UIManager : MonoBehaviour
|
||||
UIManager.Show(UIManager.Instance.EditUserPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
//LoadingPf loading;
|
||||
public static void ShowLoadingDialogBox()
|
||||
{
|
||||
if (UIManager.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//if(UIManager.Instance.loading == null)
|
||||
//{
|
||||
// UIManager.Instance.loading = UIManager.Instance.GetInstance<LoadingPf>("Loading", ref UIManager.Instance.loading);
|
||||
// UIManager.Instance.loading.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
|
||||
// //var rect = UIManager.Instance.loading.GetComponent<RectTransform>().rect;
|
||||
// //rect.width = 154;
|
||||
// //rect.height = 111;
|
||||
// UIManager.Instance.loading.GetComponent<RectTransform>().sizeDelta = new Vector2(154, 111);
|
||||
// //var rrr = UIManager.Instance.loading.GetComponent<RectTransform>();
|
||||
|
||||
// UIManager.Instance.loading.Initial();
|
||||
|
||||
// UIManager.Show(UIManager.Instance.loading, null, true);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// UIManager.Instance.loading.Show();
|
||||
//}
|
||||
Utils.showLoading(UIManager.Instance.ModalsPanel.gameObject);
|
||||
}
|
||||
|
||||
public static void HideLoadingDialogBox()
|
||||
{
|
||||
if (UIManager.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Utils.hideLoading(UIManager.Instance.ModalsPanel.gameObject);
|
||||
}
|
||||
|
||||
|
||||
public static void ShowMapListPanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.MapListPanel, UIManager.Instance.MainPanel);
|
||||
|
||||
@@ -157,8 +157,7 @@ namespace Assets.Scripts
|
||||
newLoading.transform.parent = parent;
|
||||
loading = newLoading.transform;
|
||||
}
|
||||
loading.GetComponent<LoadingPf>().Initial();
|
||||
loading.gameObject.SetActive(true);
|
||||
loading.GetComponent<LoadingPf>().Show();
|
||||
}
|
||||
public static void hideLoading(this GameObject game)
|
||||
{
|
||||
@@ -166,7 +165,8 @@ namespace Assets.Scripts
|
||||
var loading = parent.Find("Loading");
|
||||
if (loading != null)
|
||||
{
|
||||
loading.gameObject.SetActive(false);
|
||||
//loading.gameObject.SetActive(false);
|
||||
loading.GetComponent<LoadingPf>().Close();
|
||||
}
|
||||
}
|
||||
/*删除父亲节点下的所有孩子*/
|
||||
|
||||
Reference in new issue
Block a user