解决台湾无法点击的问题

This commit is contained in:
suntao 2021-05-20 16:15:53 +08:00
parent 3e38fd65c2
commit 5db375bcf5
3 changed files with 30 additions and 9 deletions

View File

@ -50,10 +50,10 @@ public static class App
static App() static App()
{ {
#if !UNITY_EDITOR //#if !UNITY_EDITOR
//Host = "http://pf.juze.pro/"; // //Host = "http://pf.juze.pro/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000); // //UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001); // //TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
#endif //#endif
} }
} }

View File

@ -183,6 +183,11 @@ namespace Assets.Scripts.Devices.Ant
} }
searchChannel.channelResponse -= antChannel_channelResponse_FeSearch; searchChannel.channelResponse -= antChannel_channelResponse_FeSearch;
searchChannel = null; searchChannel = null;
foreach (var item in discoveredDevices)
{
item.State = DeviceState.Disconnected;
}
discoveredDevices.Clear(); discoveredDevices.Clear();
usedChannels.Clear(); usedChannels.Clear();
IsBackgroundScanning = false; IsBackgroundScanning = false;

View File

@ -8,6 +8,7 @@ using Assets.Scripts.Apis;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Assets.Scripts; using Assets.Scripts;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using System;
public class EarthController : PFUIPanel public class EarthController : PFUIPanel
{ {
@ -29,6 +30,7 @@ public class EarthController : PFUIPanel
bool showSummary = false; bool showSummary = false;
Vector2 latlonCenter; Vector2 latlonCenter;
private GameObject panel; private GameObject panel;
private bool isTaiwanClick = false;
protected override void Awake() protected override void Awake()
{ {
base.Awake(); base.Awake();
@ -123,11 +125,15 @@ public class EarthController : PFUIPanel
map.OnCountryClick += (int countryIndex, int regionIndex) => map.OnCountryClick += (int countryIndex, int regionIndex) =>
{ {
var country = map.countries[countryIndex]; var country = map.countries[countryIndex];
if (country.name.ToLower().Contains("taiwan")) Debug.Log($"country click { country.name }, { countryIndex }, { regionIndex }");
if (country.name.ToLower().Contains("taiwan") || country.name.ToLower().Contains("china"))
{ {
var latLon = country.latlonCenter; //var latLon = map.countries[36].latlonCenter; //country.latlonCenter;
EnterBigMap(latLon); //EnterBigMap(latLon);
isTaiwanClick = true;
Invoke("DelayEnterBigMapForTaiwan", 0.01f);
} }
}; };
@ -148,6 +154,8 @@ public class EarthController : PFUIPanel
}; };
map.OnProvinceClick += (int provinceIndex, int regionIndex) => map.OnProvinceClick += (int provinceIndex, int regionIndex) =>
{ {
isTaiwanClick = false;
Debug.Log("province click");
var province = map.provinces[provinceIndex]; var province = map.provinces[provinceIndex];
var latLon = province.latlonCenter; var latLon = province.latlonCenter;
EnterBigMap(latLon); EnterBigMap(latLon);
@ -156,6 +164,13 @@ public class EarthController : PFUIPanel
//skybox = Camera.main.GetComponent<Skybox>(); //skybox = Camera.main.GetComponent<Skybox>();
} }
private void DelayEnterBigMapForTaiwan()
{
if (!isTaiwanClick) return;
var latLon = map.countries[36].latlonCenter;
EnterBigMap(latLon);
}
//private float rot = 0; //private float rot = 0;
//Skybox skybox; //Skybox skybox;
/// <summary> /// <summary>
@ -229,7 +244,7 @@ public class EarthController : PFUIPanel
//Debug.Log("click"); //Debug.Log("click");
Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation); Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation);
Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y); Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y);
} }
@ -280,5 +295,6 @@ public class EarthController : PFUIPanel
//base.Close(); //base.Close();
map.Destroy(); map.Destroy();
DestroyImmediate(this.gameObject); DestroyImmediate(this.gameObject);
GC.SuppressFinalize(this);
} }
} }