单点登录不在进程内运行问题;gps取定位服务的;点击图标显示毫秒
This commit is contained in:
1 parent
42e23e2f84
commit
5ba176725f
19 files changed
+1738
-1392
No files matched your search
@@ -36,7 +36,6 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
//http = new EasyHttp.Http.HttpClient();
|
||||
//http.Request.PersistCookies = true;
|
||||
|
||||
httpClientHandler = new PfHttpClientHandler();
|
||||
httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
httpClientHandler.Proxy = WebRequest.GetSystemWebProxy();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Assets.Scripts.Apis
|
||||
if (json.code == 401)
|
||||
{
|
||||
App.is401 = json.errMsg;
|
||||
UIManager.Instance.StartCoroutine(LoadLogin(json.errMsg));
|
||||
UnityMainThreadDispatcher.Instance().Enqueue(LoadLogin(json.errMsg));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,5 +23,11 @@ namespace Assets.Scripts.Apis
|
||||
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
||||
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
||||
}
|
||||
public async Task<Stream> GetMapImage(double latitude,double longitude)
|
||||
{
|
||||
return await GetThirdPartStreamAsync($"https://api.mapbox.com/styles/v1/juzetest/ckmkdjwsa1nvt17nr1ps4fqgs/static/{longitude.ToString(CultureInfo.InvariantCulture)},{latitude.ToString(CultureInfo.InvariantCulture)},12,0/1280x1280?access_token=pk.eyJ1IjoianV6ZXRlc3QiLCJhIjoiY2ttazhsbnpiMGVrdjJucGhyNnh6eXcxYSJ9.6zj2U9eFCNJRMljNlMxjVg");
|
||||
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
||||
//pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,6 +109,7 @@ public static class App
|
||||
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||||
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
|
||||
Host = "https://wx.powerfun.com.cn/";
|
||||
//Host = "http://192.168.0.101:5084/";
|
||||
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
|
||||
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
|
||||
Debug.unityLogger.logEnabled = false;
|
||||
|
||||
@@ -579,6 +579,22 @@ public class LoginController : BaseScene
|
||||
{
|
||||
if (!App.TextureCache.ContainsKey("rotateImage"))
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
StartCoroutine(Utils.StartLocation(async loc =>
|
||||
{
|
||||
App.latitude = loc.latitude;
|
||||
App.longitude = loc.longitude;
|
||||
var i = await ConfigHelper.thirdPartApi.GetMapImage(loc.latitude,loc.longitude);
|
||||
var t = new Texture2D(4, 4,TextureFormat.ASTC_RGB_4x4, false);
|
||||
if (t.LoadImage(Utils.StreamToBytes(i)))
|
||||
{
|
||||
Debug.Log("成功");
|
||||
App.TextureCache["rotateImage"] = t;
|
||||
Utils.WriteTextureToPlayerPrefs("rotateImage", t);
|
||||
}
|
||||
}));
|
||||
#else
|
||||
|
||||
var locationInfo = await ConfigHelper.thirdPartApi.GetLocationInfo();
|
||||
App.latitude = locationInfo.latitude;
|
||||
App.longitude = locationInfo.longitude;
|
||||
@@ -595,7 +611,7 @@ public class LoginController : BaseScene
|
||||
//}
|
||||
Debug.Log(JsonConvert.SerializeObject(locationInfo));
|
||||
var i = await ConfigHelper.thirdPartApi.GetMapImage(locationInfo);
|
||||
var t = new Texture2D(2, 2);
|
||||
var t = new Texture2D(4, 4,TextureFormat.DXT5, false);
|
||||
if (t.LoadImage(Utils.StreamToBytes(i)))
|
||||
{
|
||||
Debug.Log("成功");
|
||||
@@ -606,6 +622,7 @@ public class LoginController : BaseScene
|
||||
//Utils.DownloadImageToLocal(StartCoroutine,
|
||||
//$"https://api.mapbox.com/styles/v1/mapbox/dark-v10/static/{locationInfo.longitude},{locationInfo.latitude},12.14,0/1280x1280?access_token=pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA",
|
||||
//"rotateImage");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Assets.Scripts.UI.Control
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool showTooltip { get; set; }
|
||||
private void BindEvent()
|
||||
{
|
||||
//鼠标进入
|
||||
@@ -113,11 +113,14 @@ namespace Assets.Scripts.UI.Control
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips))
|
||||
{
|
||||
#else
|
||||
if (!string.IsNullOrWhiteSpace(Tooltips) && showTooltip)
|
||||
{
|
||||
#endif
|
||||
tooltips.GetComponent<CanvasGroup>().alpha = 0f;
|
||||
tooltips.SetActive(true);
|
||||
tooltips.GetComponent<CanvasGroup>().DOFade(1f, 0.2f);
|
||||
}
|
||||
#endif
|
||||
switch (mType)
|
||||
{
|
||||
case Type.Normal:
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -33,7 +34,7 @@ public class MainNav : MonoBehaviour
|
||||
exit = this.transform.Find("Exit").gameObject;
|
||||
exit.SetActive(false);
|
||||
|
||||
|
||||
transform.Find("Delay").GetComponent<PfUIButton>().showTooltip = true;
|
||||
UIManager.AddEvent(exit, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", ()=> {
|
||||
|
||||
@@ -21,7 +21,11 @@ public class MapListController : PFUIPanel
|
||||
[SerializeField] GameObject content;
|
||||
[SerializeField] GameObject scroll;
|
||||
[HideInInspector] public int pageIndex = 0;
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
[HideInInspector] public int pageSize = 21;
|
||||
#else
|
||||
[HideInInspector] public int pageSize = 20;
|
||||
#endif
|
||||
[HideInInspector] public string hard = "全部";
|
||||
private Transform distanceOptions;
|
||||
private Transform diffOptions;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
|
||||
public class UnityMainThreadDispatcher : MonoBehaviour
|
||||
{
|
||||
|
||||
private static readonly Queue<Action> _executionQueue = new Queue<Action>();
|
||||
|
||||
/// <summary>
|
||||
/// Locks the queue and adds the IEnumerator to the queue
|
||||
/// </summary>
|
||||
/// <param name="action">IEnumerator function that will be executed from the main thread.</param>
|
||||
public void Enqueue(IEnumerator action)
|
||||
{
|
||||
lock (_executionQueue)
|
||||
{
|
||||
_executionQueue.Enqueue(() => {
|
||||
StartCoroutine(action);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks the queue and adds the Action to the queue
|
||||
/// </summary>
|
||||
/// <param name="action">function that will be executed from the main thread.</param>
|
||||
public void Enqueue(Action action)
|
||||
{
|
||||
Enqueue(ActionWrapper(action));
|
||||
}
|
||||
IEnumerator ActionWrapper(Action a)
|
||||
{
|
||||
a();
|
||||
yield return null;
|
||||
}
|
||||
|
||||
|
||||
private static UnityMainThreadDispatcher _instance = null;
|
||||
|
||||
public static bool Exists()
|
||||
{
|
||||
return _instance != null;
|
||||
}
|
||||
|
||||
public static UnityMainThreadDispatcher Instance()
|
||||
{
|
||||
if (!Exists())
|
||||
{
|
||||
throw new Exception("UnityMainThreadDispatcher could not find the UnityMainThreadDispatcher object. Please ensure you have added the MainThreadExecutor Prefab to your scene.");
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = this;
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
lock (_executionQueue)
|
||||
{
|
||||
while (_executionQueue.Count > 0)
|
||||
{
|
||||
_executionQueue.Dequeue().Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//void OnDestroy()
|
||||
//{
|
||||
// Debug.Log(79 + "清掉dispatch");
|
||||
// _instance = null;
|
||||
//}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 701a01d99aaa00c48a78af9bae9c2eda
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -453,8 +453,11 @@ namespace Assets.Scripts
|
||||
{
|
||||
// convert it to byte array
|
||||
byte[] texByte = System.Convert.FromBase64String(base64Tex);
|
||||
Texture2D tex = new Texture2D(2, 2);
|
||||
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
Texture2D tex = new Texture2D(4, 4, TextureFormat.ASTC_RGB_4x4,false);
|
||||
#else
|
||||
Texture2D tex = new Texture2D(4, 4, TextureFormat.DXT5,false);
|
||||
#endif
|
||||
//load texture from byte array
|
||||
if (tex.LoadImage(texByte))
|
||||
{
|
||||
@@ -648,5 +651,48 @@ namespace Assets.Scripts
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public static IEnumerator StartLocation(Action<LocationInfo> action = null)
|
||||
{
|
||||
// Check if the user has location service enabled.
|
||||
if (!Input.location.isEnabledByUser)
|
||||
yield break;
|
||||
|
||||
// Starts the location service.
|
||||
Input.location.Start();
|
||||
|
||||
// Waits until the location service initializes
|
||||
int maxWait = 20;
|
||||
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
|
||||
{
|
||||
yield return new WaitForSeconds(1);
|
||||
maxWait--;
|
||||
}
|
||||
|
||||
// If the service didn't initialize in 20 seconds this cancels location service use.
|
||||
if (maxWait < 1)
|
||||
{
|
||||
Debug.Log("Timed out");
|
||||
yield break;
|
||||
}
|
||||
|
||||
// If the connection failed this cancels location service use.
|
||||
if (Input.location.status == LocationServiceStatus.Failed)
|
||||
{
|
||||
Debug.Log("Unable to determine device location");
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the connection succeeded, this retrieves the device's current location and displays it in the Console window.
|
||||
Debug.Log("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
|
||||
if (action != null)
|
||||
{
|
||||
action.Invoke(Input.location.lastData);
|
||||
}
|
||||
}
|
||||
|
||||
// Stops the location service if there is no need to query location updates continuously.
|
||||
Input.location.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user