Merge remote-tracking branch 'origin/dev' into dev_lishuo
# Conflicts: # Assets/Scripts/Apis/MapApi.cs # Assets/Scripts/App.cs
This commit is contained in:
commit
62938ec6ae
170 files changed
+29085
-18769
No files matched your search
@@ -78,7 +78,12 @@ namespace Assets.Scripts.Apis
|
||||
protected async Task<byte[]> GetAsync(string url)
|
||||
{
|
||||
AddLanguage();
|
||||
var httpResponseMessage = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
var _url = url;
|
||||
if(_url.IndexOf("http") == -1)
|
||||
{
|
||||
_url = ConfigHelper.Host + url;
|
||||
}
|
||||
var httpResponseMessage = await httpClient.GetAsync(_url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
if (!httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
return null;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -55,9 +56,9 @@ namespace Assets.Scripts.Apis
|
||||
/// <param name="sort">hot, distance</param>
|
||||
/// <param name="sortDire">asc</param>
|
||||
/// <returns></returns>
|
||||
public JsonResult<List<MapRoute>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "")
|
||||
public JsonResult<List<MapRoute>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "", bool isFav = false)
|
||||
{
|
||||
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }";
|
||||
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }&isFav={isFav}";
|
||||
|
||||
return Get<JsonResult<List<MapRoute>>>(url);
|
||||
}
|
||||
@@ -87,6 +88,22 @@ namespace Assets.Scripts.Apis
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public async Task<JsonResult<List<NearRouteModel>>> GetNearRouteAsync(float lat, float lng, float zoom, string bounds)
|
||||
{
|
||||
var res = await GetAsync<JsonResult<List<NearRouteModel>>>($"/Map/GetNearRoute?lat={ lat }&lng={ lng }&zoom={zoom}&bounds={ bounds }");
|
||||
|
||||
//var result = System.Text.Encoding.UTF8.GetString(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<string> GetDetailsAsync(int[] ids)
|
||||
{
|
||||
var res = await GetAsync("/Map/GetDetails?ids=" + string.Join(",", ids));
|
||||
|
||||
return Encoding.UTF8.GetString(res);
|
||||
}
|
||||
|
||||
public JsonResult<MapRouteRankingList> GetRouteRanking(int id,string type, int pageIndex,int pageSize,string name)
|
||||
{
|
||||
var url = $"Map/v1/GetRouteRanking?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&id={ id }&type={ type }&filterSelf={ true }";
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class MapBoxApi: ApiBase
|
||||
{
|
||||
public 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);
|
||||
|
||||
//return System.Text.Encoding.UTF8.GetString(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 969b87ed3066bec4a9981a69d7dfb8e4
|
||||
guid: 97ae508c230356844bf73819c3e1b451
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,10 +1,12 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
@@ -21,5 +23,28 @@ namespace Assets.Scripts.Apis
|
||||
var jsonResult = JsonConvert.DeserializeObject<JsonResult<AddMapRecordResultModel>>(result);
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
public JsonResult<List<RouteResult>> GetMapInterruptRecord(string keyword, int pageIndex, int pageSize)
|
||||
{
|
||||
var result = new JsonResult<List<RouteResult>>()
|
||||
{
|
||||
result = false,
|
||||
data = null,
|
||||
errMsg = ""
|
||||
};
|
||||
try
|
||||
{
|
||||
var r = Get<List<RouteResult>>($"MapRecord/GetMapInterruptRecord?keyword={keyword}&pageIndex={pageIndex}&pageSize={pageSize}");
|
||||
result.result = true;
|
||||
result.data = r;
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Log(e.ToString());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,5 +100,7 @@ namespace Assets.Scripts.Apis.Models
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
public bool Enable3D { get; set; }
|
||||
public int TheHeat { get; set; }
|
||||
public string Hard { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class NearRouteModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string DirPath { get; set; }
|
||||
public string CreateTime { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public double Distance { get; set; }
|
||||
public double EleDifference { get; set; }
|
||||
public double TotalClimb { get; set; }
|
||||
public double AverageGrade { get; set; }
|
||||
public string CoverImage { get; set; }
|
||||
public string ElevationPath { get; set; }
|
||||
public List<double> Point { get; set; }
|
||||
public string Address { get; set; }
|
||||
/// <summary>
|
||||
/// 骑行热度
|
||||
/// </summary>
|
||||
public int TheHeat { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df1953478a7c274448dcde606e6718e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class RouteResultParam
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int? OnlineUserId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ContinueMark { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int? ContinueIndex { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int? RouteId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int? CompetitionId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double EndDistance { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string RankingsId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string GlobalContinue { get; set; }
|
||||
}
|
||||
public class RouteResult
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int RankingId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string IsCompleted { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string IsDelete { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string ManufacturerName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int MapCompetitionId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public List<double> Point { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double Progress { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int RouteId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string RouteImage { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string RouteName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double TotalDistance { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Ticks { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string TrainingTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int UserId { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double EndDistance { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Mode { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double TripDistance { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CanAgain { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public RouteResultParam Param { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CanContinueCycling { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public RouteResultParam ContinueCyclingParam { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Count { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CyclingEquipmentName { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CanDelete { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public int Ranking { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public double CurrentRouteStartDistance { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string CanShareOnStrava { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20fedef2ea43f1749a5492c955936068
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -115,9 +115,9 @@ namespace Assets.Scripts.Apis
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public async Task<JsonResult<object>> GetCaptcha(string phone)
|
||||
public async Task<JsonResult<JObject>> GetCaptcha(string phone)
|
||||
{
|
||||
return await PostAsync<JsonResult<object>>("NoAuth/v1/GetCaptcha",new {phone });
|
||||
return await PostAsync<JsonResult<JObject>>("NoAuth/v1/GetCaptcha",new {phone });
|
||||
}
|
||||
public async Task<JsonResult<object>> UpdateUserInfo(UserResultModel user)
|
||||
{
|
||||
@@ -127,6 +127,10 @@ namespace Assets.Scripts.Apis
|
||||
{
|
||||
return Get<JsonResult<JObject>>("User/GetCurrentUser");
|
||||
}
|
||||
public async Task<JsonResult<UserResultModel>> QuickLogin()
|
||||
{
|
||||
return await PostAsync<JsonResult<UserResultModel>>("NoAuth/QuickLogin",null);
|
||||
}
|
||||
|
||||
public async Task<JsonResult<object>> OnWebWxLoginCheckUnionId(string unionId, string openId)
|
||||
{
|
||||
|
||||
@@ -14,6 +14,15 @@ public static class App
|
||||
public static UserResultModel CurrentUser { get; set; }
|
||||
public static string WxAppId = "wx9e8ca734e024f084";
|
||||
public static string WxAppSecret = "906abafb2a18bc7a66ccfa5550f859b6";
|
||||
|
||||
public static string MapBoxAccessToken => "pk.eyJ1IjoiYW5keXNqdCIsImEiOiJja2ZhajE5OGwwamRiMnltcW96bHk0ZWFuIn0.GvKanc6UveWSvIjS9HfBPA";
|
||||
|
||||
/// <summary>
|
||||
/// 场景跳转传值
|
||||
/// Name,MapListPanel
|
||||
/// xxx,bbb
|
||||
/// </summary>
|
||||
public static System.Collections.Generic.Dictionary<string, string> MainSceneParam = new Dictionary<string, string>();
|
||||
public static IDictionary<string,Texture> TextureCache = new Dictionary<string, Texture>();
|
||||
public static SelectParamModel selectParam;
|
||||
}
|
||||
@@ -27,6 +27,11 @@ public class QUserInfo
|
||||
public string Avatar { get; set; }
|
||||
public string Cookie { get; set; }
|
||||
}
|
||||
public class LoginForm
|
||||
{
|
||||
public InputField email { get; set; }
|
||||
public InputField password { get; set; }
|
||||
}
|
||||
public class SignForm
|
||||
{
|
||||
//页面1
|
||||
@@ -46,31 +51,32 @@ public class SignForm
|
||||
}
|
||||
public class LoginController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] InputField[] loginForm;
|
||||
[SerializeField] Button login;
|
||||
[SerializeField] Button loginNewAccount;
|
||||
private Transform mainContent;
|
||||
/*初始页面*/
|
||||
private Transform quickContainer;
|
||||
private Transform loginContainer;
|
||||
private Transform signContainer;
|
||||
/*初始页面*/
|
||||
LoginForm loginForm;
|
||||
[SerializeField] Button loginReturn2;
|
||||
[SerializeField] Button returnQuick;
|
||||
[SerializeField] Button sign;
|
||||
[SerializeField] Button remember;
|
||||
[SerializeField] Button wechatLogin;
|
||||
private Button remember;
|
||||
/*滑动相关*/
|
||||
[SerializeField] GameObject loginScrollView;
|
||||
[SerializeField] GameObject signScrollView;
|
||||
[SerializeField] GameObject avatarScrollView;
|
||||
/*滑动相关*/
|
||||
//注册
|
||||
private Transform signPage1;
|
||||
private Transform signPage2;
|
||||
private Transform signScrollBar;
|
||||
private SignForm signForm;
|
||||
private LoginRegOptions regOptions;
|
||||
[SerializeField] GameObject avatarScrollView;
|
||||
[SerializeField] RawImage loading;
|
||||
[SerializeField] Button exit;
|
||||
|
||||
private ScrollRect scrollPanel;
|
||||
private ScrollRect scrollSign;
|
||||
private ScrollRect scrollAvatar;
|
||||
private Transform imagexf;
|
||||
private Transform mainContent;
|
||||
//注册主页面
|
||||
private Transform signContainer;
|
||||
private UserResultModel userResult;
|
||||
/*微信相关*/
|
||||
private Browser wxBrowser;
|
||||
@@ -81,8 +87,13 @@ public class LoginController : MonoBehaviour
|
||||
private JObject wxInfoJson;
|
||||
private bool wxLock;
|
||||
/*微信相关*/
|
||||
|
||||
private List<QUserInfo> userInfos;
|
||||
|
||||
/*退出按钮*/
|
||||
[SerializeField] Button exit;
|
||||
/*退出按钮*/
|
||||
//其他
|
||||
[SerializeField] RawImage loading;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
@@ -92,24 +103,21 @@ public class LoginController : MonoBehaviour
|
||||
//userInfos.RemoveAt(0);
|
||||
//PlayerPrefs.SetString("UserInfos", "");
|
||||
//transform.Find("RawImage").DOMove(new Vector3(0.5f,0.5f,0),1);
|
||||
if (loginForm.Length == 2 && loginForm[0] != null && loginForm[1] != null)
|
||||
{
|
||||
foreach (var ipt in loginForm)
|
||||
{
|
||||
UIManager.AddEvent(ipt.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>
|
||||
((BaseEventData arg0) => { OnLoginInputSelect(arg0, ipt.gameObject); }));
|
||||
UIManager.AddEvent(ipt.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>
|
||||
((BaseEventData arg0) => { OnLoginInputSelect(arg0, ipt.gameObject); }));
|
||||
UIManager.AddEvent(ipt.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>
|
||||
((BaseEventData arg0) => { OnLoginInputDeSelect(arg0, ipt.gameObject); }));
|
||||
}
|
||||
//loginForm[0].
|
||||
}
|
||||
if (login != null)
|
||||
{
|
||||
login.onClick.AddListener(Submit);
|
||||
//login.onClick.AddListener(Submit);
|
||||
}
|
||||
|
||||
//if (loginForm.Length == 2 && loginForm[0] != null && loginForm[1] != null)
|
||||
//{
|
||||
// foreach (var ipt in loginForm)
|
||||
// {
|
||||
// UIManager.AddEvent(ipt.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>
|
||||
// ((BaseEventData arg0) => { OnLoginInputSelect(arg0, ipt.gameObject); }));
|
||||
// UIManager.AddEvent(ipt.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>
|
||||
// ((BaseEventData arg0) => { OnLoginInputSelect(arg0, ipt.gameObject); }));
|
||||
// UIManager.AddEvent(ipt.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>
|
||||
// ((BaseEventData arg0) => { OnLoginInputDeSelect(arg0, ipt.gameObject); }));
|
||||
// }
|
||||
// //loginForm[0].
|
||||
//}
|
||||
|
||||
if (loading != null)
|
||||
{
|
||||
loading.texture.wrapMode = TextureWrapMode.Repeat;
|
||||
@@ -118,6 +126,9 @@ public class LoginController : MonoBehaviour
|
||||
{
|
||||
scrollPanel = loginScrollView.GetComponent<ScrollRect>();
|
||||
mainContent = loginScrollView.transform.Find("Viewport").Find("Content");
|
||||
quickContainer = mainContent.Find("FormContainer-Quick");
|
||||
loginContainer = mainContent.Find("FormContainer-Login").Find("FormContainer");
|
||||
signContainer = mainContent.Find("FormContainer-Sign");
|
||||
}
|
||||
if (signScrollView != null)
|
||||
{
|
||||
@@ -208,29 +219,18 @@ public class LoginController : MonoBehaviour
|
||||
content.Find("empty2").transform.SetSiblingIndex(content.childCount-1);
|
||||
scrollAvatar.GetComponent<QuickLoginScroll>().Initial();
|
||||
}
|
||||
if (loginNewAccount != null)
|
||||
if (quickContainer != null)
|
||||
{
|
||||
var loginNewAccount = quickContainer.Find("loginNewAccount").GetComponent<Button>();
|
||||
loginNewAccount.onClick.AddListener(goLogin);
|
||||
}
|
||||
if (returnQuick != null)
|
||||
if (loginContainer != null)
|
||||
{
|
||||
var returnQuick = loginContainer.Find("returnQuick").GetComponent<Button>();
|
||||
returnQuick.onClick.AddListener(ReturnQuick);
|
||||
}
|
||||
if (sign != null)
|
||||
{
|
||||
sign.onClick.AddListener(()=>goSign());
|
||||
}
|
||||
if (loginReturn2 != null)
|
||||
{
|
||||
loginReturn2.onClick.AddListener(goLoginReturn2);
|
||||
}
|
||||
if (exit != null)
|
||||
{
|
||||
exit.onClick.AddListener(() => Application.Quit());
|
||||
}
|
||||
signContainer = mainContent.Find("FormContainer-Sign");
|
||||
if (remember != null)
|
||||
{
|
||||
var sign = loginContainer.Find("reg").GetComponent<Button>();
|
||||
sign.onClick.AddListener(() => goSign());
|
||||
remember = loginContainer.Find("rememberButton").GetComponent<Button>();
|
||||
remember.onClick.AddListener(() =>
|
||||
{
|
||||
var gou = remember.transform.Find("Gou");
|
||||
@@ -243,29 +243,49 @@ public class LoginController : MonoBehaviour
|
||||
gou.gameObject.SetActive(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (wechatLogin != null)
|
||||
{
|
||||
var wechatLogin = loginContainer.Find("otherContainer").Find("Wechat").GetComponent<Button>();
|
||||
wechatLogin.onClick.AddListener(() =>
|
||||
{
|
||||
if (wxLock) return;
|
||||
wxLock = true;
|
||||
|
||||
wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1,5)).ToString();
|
||||
|
||||
wxState = (DateTime.Now.ToUniversalTime().Ticks / 10000 * new System.Random().Next(1, 5)).ToString();
|
||||
wxBrowser.Url = $"https://open.weixin.qq.com/connect/qrconnect?appid={App.WxAppId}&redirect_uri=https%3A%2F%2Fwx.powerfun.com.cn%2FNoAuth%2Fv1%2FWxWebLogin&response_type=code&scope=snsapi_login&state={wxState}#wechat_redirect";
|
||||
AdjustWxQrCode();
|
||||
//AdjustWxQrCode();
|
||||
var wx1 = mainContent.Find("FormContainer-Login").Find("FormContainer-wx1");
|
||||
wx1.gameObject.SetActive(true);
|
||||
Debug.Log(178+ "已经开启"+ wx1.gameObject.activeSelf);
|
||||
wx1.DOLocalMoveY(0, 0.3f).onComplete = ()=> { wxLock = false; };
|
||||
Debug.Log(178 + "已经开启" + wx1.gameObject.activeSelf);
|
||||
wx1.DOLocalMoveY(0, 0.3f).onComplete = () => { wxLock = false; };
|
||||
});
|
||||
var login = loginContainer.Find("login").GetComponent<Button>();
|
||||
login.onClick.AddListener(Submit);
|
||||
loginForm = new LoginForm()
|
||||
{
|
||||
email = loginContainer.Find("phone").GetComponent<InputField>(),
|
||||
password = loginContainer.Find("pwd").GetComponent<InputField>()
|
||||
};
|
||||
}
|
||||
//if (loginReturn2 != null)
|
||||
//{
|
||||
// loginReturn2.onClick.AddListener(goLoginReturn2);
|
||||
//}
|
||||
if (signContainer != null)
|
||||
{
|
||||
var loginr2 = signContainer.Find("loginr2").GetComponent<Button>();
|
||||
loginr2.onClick.AddListener(goLoginReturn2);
|
||||
}
|
||||
if (exit != null)
|
||||
{
|
||||
exit.onClick.AddListener(() => Application.Quit());
|
||||
}
|
||||
|
||||
wxLogin1 = mainContent.Find("FormContainer-Login").Find("FormContainer-wx1");
|
||||
if (wxLogin1 != null)
|
||||
{
|
||||
wxLogin1.Find("Image").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
wxLock = true;
|
||||
wxBrowser.Url = "chrome://version/";
|
||||
wxLogin1.DOMoveY(-573, 0.8f).onComplete = () =>
|
||||
{
|
||||
wxLock = false;
|
||||
@@ -338,12 +358,11 @@ public class LoginController : MonoBehaviour
|
||||
});
|
||||
}
|
||||
imagexf = transform.Find("Panel").Find("LoginContainer").Find("Imagexf");
|
||||
|
||||
|
||||
}
|
||||
private void AdjustWxQrCode()
|
||||
{
|
||||
wxBrowser.EvalJS(@"
|
||||
console.log(document.getElementsByClassName('qrcode')[0]);
|
||||
document.getElementsByClassName('qrcode')[0].style.marginTop = 0;
|
||||
document.getElementsByClassName('title')[0].style.display = 'none';
|
||||
document.body.style.background = '#272732';
|
||||
@@ -397,12 +416,12 @@ public class LoginController : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
userResult = data.ToObject<UserResultModel>();
|
||||
RefreshWx3(data.ToObject<UserResultModel>());
|
||||
wxLogin3.gameObject.SetActive(true);
|
||||
Utils.DisplayImage(StartCoroutine,
|
||||
wxLogin3.Find("Avatar").GetComponent<RawImage>(),
|
||||
wxInfoJson.Value<string>("headimgurl"));
|
||||
wxLogin3.Find("NickName").GetComponent<Text>().text = wxInfoJson.Value<string>("nickname");
|
||||
//Utils.DisplayImage(StartCoroutine,
|
||||
//wxLogin3.Find("Avatar").GetComponent<RawImage>(),
|
||||
//wxInfoJson.Value<string>("headimgurl"));
|
||||
//wxLogin3.Find("NickName").GetComponent<Text>().text = wxInfoJson.Value<string>("nickname");
|
||||
signContainer.gameObject.SetActive(false);
|
||||
pageNums = 3;
|
||||
//this.goSign();
|
||||
@@ -444,6 +463,10 @@ public class LoginController : MonoBehaviour
|
||||
//Timer t = new Ti
|
||||
if (r.result)
|
||||
{
|
||||
if (r.data.Value<bool>("isExist") && pageNums == 5)
|
||||
{
|
||||
HidePassword();
|
||||
}
|
||||
time = 60;
|
||||
btnText.text = $"Again({time})";
|
||||
System.Timers.Timer timer = new System.Timers.Timer();
|
||||
@@ -461,6 +484,22 @@ public class LoginController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void HidePassword()
|
||||
{
|
||||
signPage1.Find("Password").gameObject.SetActive(false);
|
||||
signPage1.Find("CPassword").gameObject.SetActive(false);
|
||||
signPage1.Find("signThird").GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(goRegNextWithoutPass);
|
||||
}
|
||||
|
||||
|
||||
void ShowPassword()
|
||||
{
|
||||
signPage1.Find("Password").gameObject.SetActive(true);
|
||||
signPage1.Find("CPassword").gameObject.SetActive(true);
|
||||
signPage1.Find("signThird").GetComponent<Button>().onClick.RemoveAllListeners();
|
||||
signPage1.Find("signThird").GetComponent<Button>().onClick.AddListener(() => { goRegNext(1); });
|
||||
}
|
||||
void CaptchaTimerTick()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
@@ -507,6 +546,11 @@ public class LoginController : MonoBehaviour
|
||||
var Captcha = signForm.captcha;
|
||||
var Password = signForm.password;
|
||||
var CPassword = signForm.cpassword;
|
||||
if (Password.text != CPassword.text)
|
||||
{
|
||||
Utils.showToast(gameObject,"两次密码输入不一致");
|
||||
return;
|
||||
}
|
||||
//JsonConvert
|
||||
JsonResult<UserResultModel> r = null;
|
||||
if (signType == 0)
|
||||
@@ -526,14 +570,44 @@ public class LoginController : MonoBehaviour
|
||||
}
|
||||
if (r!=null && r.result)
|
||||
{
|
||||
RefreshWx3(r.data);
|
||||
StartScrollSign(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartScrollSign(1);
|
||||
//Utils.showToast(gameObject, r.errMsg, 1);
|
||||
Utils.showToast(gameObject, r.errMsg, 1);
|
||||
}
|
||||
}
|
||||
async void goRegNextWithoutPass()
|
||||
{
|
||||
var Email = signForm.email;
|
||||
var Captcha = signForm.captcha;
|
||||
var r = await ConfigHelper.userApi.OnWebWxLogin(Email.text,
|
||||
Captcha.text,
|
||||
wxInfoJson.Value<string>("unionid"),
|
||||
wxInfoJson.Value<string>("openid"),
|
||||
wxInfoJson.Value<string>("headimgurl"),
|
||||
wxInfoJson.Value<string>("nickname"),
|
||||
wxInfoJson.Value<int>("sex"),
|
||||
"");
|
||||
if (r.result)
|
||||
{
|
||||
RefreshWx3(r.data);
|
||||
StartScrollPanel(4);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
}
|
||||
void RefreshWx3(UserResultModel data)
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine,
|
||||
wxLogin3.Find("Avatar").GetComponent<RawImage>(),
|
||||
data.WxHeadImg);
|
||||
wxLogin3.Find("NickName").GetComponent<Text>().text = data.Nickname;
|
||||
userResult = data;
|
||||
}
|
||||
private void goRegEnd()
|
||||
{
|
||||
if (pageNums == 5)
|
||||
@@ -577,6 +651,7 @@ public class LoginController : MonoBehaviour
|
||||
signPage1.Find("next").gameObject.SetActive(false);
|
||||
signPage1.Find("previousThird").gameObject.SetActive(true);
|
||||
signPage1.Find("signThird").gameObject.SetActive(true);
|
||||
ShowPassword();
|
||||
this.StartScrollPanel(3);
|
||||
this.StartScrollSign(0);
|
||||
}
|
||||
@@ -588,6 +663,7 @@ public class LoginController : MonoBehaviour
|
||||
signPage1.Find("next").gameObject.SetActive(true);
|
||||
signPage1.Find("previousThird").gameObject.SetActive(false);
|
||||
signPage1.Find("signThird").gameObject.SetActive(false);
|
||||
ShowPassword();
|
||||
this.StartScrollPanel(2);
|
||||
this.StartScrollSign(0);
|
||||
}
|
||||
@@ -609,6 +685,7 @@ public class LoginController : MonoBehaviour
|
||||
});
|
||||
PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
|
||||
}
|
||||
App.CurrentUser = data;
|
||||
//App.CurrentUser = new UserModel
|
||||
//{
|
||||
// NickName = data.Nickname,
|
||||
@@ -624,19 +701,19 @@ public class LoginController : MonoBehaviour
|
||||
}
|
||||
async void Submit()
|
||||
{
|
||||
if (loginForm[0] == null || loginForm[1] == null)
|
||||
if (loginForm.email == null || loginForm.password == null)
|
||||
{
|
||||
Utils.showToast(gameObject, "未绑定", 1);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(loginForm[0].text) || string.IsNullOrEmpty(loginForm[1].text))
|
||||
if (string.IsNullOrEmpty(loginForm.email.text) || string.IsNullOrEmpty(loginForm.password.text))
|
||||
{
|
||||
Utils.showToast(gameObject, "请输入信息", 1);
|
||||
return;
|
||||
}
|
||||
//var res = await Global.userApi.Login(phone.text, pwd.text, "");
|
||||
//测试用
|
||||
var res = await ConfigHelper.userApi.Login(loginForm[0].text, loginForm[1].text, "");
|
||||
var res = await ConfigHelper.userApi.Login(loginForm.email.text, loginForm.password.text, "");
|
||||
//var res = await NoAuthApi.Login(phone.text, pwd.text);
|
||||
if (res.result)
|
||||
{
|
||||
@@ -652,9 +729,9 @@ public class LoginController : MonoBehaviour
|
||||
void Update()
|
||||
{
|
||||
//Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
|
||||
if (loginForm[0].isFocused && loginForm[1] != null && Input.GetKeyDown(KeyCode.Tab))
|
||||
if (Input.GetKeyDown(KeyCode.Tab) && loginForm !=null && loginForm.email.isFocused && loginForm.password != null)
|
||||
{
|
||||
loginForm[1].ActivateInputField();
|
||||
loginForm.password.ActivateInputField();
|
||||
}
|
||||
if (startCaptcha)
|
||||
{
|
||||
|
||||
@@ -1,24 +1,41 @@
|
||||
using System.Collections;
|
||||
using Mapbox.Examples;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MainController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]GameObject root;
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
UIManager.Instance.Root = root;
|
||||
UIManager.Instance.MainPanel = this.transform.Find("Panel").GetComponent<PFUIPanel>();
|
||||
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
|
||||
|
||||
|
||||
//MainMenu.transform.Find("Home").GetComponent<Button>().onClick.AddListener(() =>
|
||||
//{
|
||||
// UIManager.ShowHomePanel();
|
||||
//});
|
||||
|
||||
UIManager.ShowHomePanel();
|
||||
//UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowEditUserPanel();
|
||||
if (App.MainSceneParam.ContainsKey("Name"))
|
||||
{
|
||||
if(App.MainSceneParam["Name"] == "MapListPanel")
|
||||
{
|
||||
UIManager.ShowMapListPanel();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
//UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowEditUserPanel();
|
||||
//UIManager.ShowBigMapPanel();
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
[RequireComponent(typeof(Button))]
|
||||
public class PFUIRoundButton : PFUIComponentBase
|
||||
{
|
||||
private Image image;
|
||||
private Text text;
|
||||
protected void Awake()
|
||||
{
|
||||
image = gameObject.GetComponent<Image>();
|
||||
text = this.transform.Find("Text").GetComponent<Text>();
|
||||
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0));
|
||||
image.material = material;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a96e12724c645a498af7c9434c9170f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -21,9 +21,10 @@ namespace Assets.Scripts.UI.Control
|
||||
|
||||
[SerializeField] Type mType;
|
||||
private Image image;
|
||||
private Text text;
|
||||
public Text text;
|
||||
private Texture2D cursor;
|
||||
private Outline outline;
|
||||
|
||||
protected void Awake()
|
||||
{
|
||||
outline = this.GetComponent<Outline>();
|
||||
@@ -65,6 +66,8 @@ namespace Assets.Scripts.UI.Control
|
||||
case Type.Border:
|
||||
{
|
||||
outline.enabled = true;
|
||||
outline.effectColor = ConvertColor("#474759");
|
||||
|
||||
image.color = ConvertColor("#3D3E4D");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7c432b0271757f4b86f715ecc5ef931
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraRectAutoFit : MonoBehaviour
|
||||
{
|
||||
float targetaspect = 16.0f / 9.0f;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
// determine the game window's current aspect ratio
|
||||
float windowaspect = (float)Screen.width / (float)Screen.height;
|
||||
// current viewport height should be scaled by this amount
|
||||
float scaleheight = windowaspect / targetaspect;
|
||||
// obtain camera component so we can modify its viewport
|
||||
Camera camera = Camera.main;
|
||||
// if scaled height is less than current height, add letterbox
|
||||
if (scaleheight <= 1.0f)
|
||||
{
|
||||
Rect rect = camera.rect;
|
||||
rect.width = 1.0f;
|
||||
rect.height = scaleheight;
|
||||
rect.x = 0;
|
||||
rect.y = (1.0f - scaleheight) / 2.0f;
|
||||
camera.rect = rect;
|
||||
}
|
||||
else // add pillarbox
|
||||
{
|
||||
float scalewidth = 1.0f / scaleheight;
|
||||
Rect rect = camera.rect;
|
||||
rect.width = scalewidth;
|
||||
rect.height = 1.0f;
|
||||
rect.x = (1.0f - scalewidth) / 2.0f;
|
||||
rect.y = 0;
|
||||
camera.rect = rect;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3083a61e316cc854fb0fa28e7fd7e237
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,117 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.UIEffect;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Item : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
private Text text;
|
||||
|
||||
private string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return text.text;
|
||||
}
|
||||
set
|
||||
{
|
||||
text.text = value;
|
||||
}
|
||||
}
|
||||
|
||||
private Text km;
|
||||
private string Distance
|
||||
{
|
||||
get
|
||||
{
|
||||
return km.text;
|
||||
}
|
||||
set
|
||||
{
|
||||
km.text = value;
|
||||
}
|
||||
}
|
||||
private Text count;
|
||||
private string Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return count.text;
|
||||
}
|
||||
set
|
||||
{
|
||||
count.text = value;
|
||||
}
|
||||
}
|
||||
public Action onClick;
|
||||
private void Awake()
|
||||
{
|
||||
text = this.transform.Find("name").GetComponent<Text>();
|
||||
km = this.transform.Find("km").GetComponent<Text>();
|
||||
count = this.transform.Find("count").GetComponent<Text>();
|
||||
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0));
|
||||
this.GetComponent<Image>().material = material;
|
||||
}
|
||||
|
||||
public void Selected(bool value)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
this.GetComponent<UIGradient>().enabled = true;
|
||||
this.GetComponent<UIGradient>().color1 = Utils.HexToColor("FF7485");
|
||||
this.GetComponent<UIGradient>().color2 = Utils.HexToColor("F93086");
|
||||
|
||||
this.GetComponent<Image>().color = Color.white;
|
||||
this.transform.Find("km").GetComponent<Text>().color = Color.white;
|
||||
this.transform.Find("count").GetComponent<Text>().color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.GetComponent<UIGradient>().enabled = false;
|
||||
this.GetComponent<Image>().color = Utils.HexToColor("353543");
|
||||
this.transform.Find("km").GetComponent<Text>().color = Utils.HexToColor("5C5C6E");
|
||||
this.transform.Find("count").GetComponent<Text>().color = Utils.HexToColor("F93086");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetModel(NearRouteModel model)
|
||||
{
|
||||
this.Text = model.Name;
|
||||
this.Distance = model.Distance + "KM";
|
||||
this.Count = model.TheHeat.ToString();
|
||||
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if(onClick != null)
|
||||
{
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4798070a21cb55b40a0a89ac2b84f135
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Tips : MonoBehaviour
|
||||
{
|
||||
public NearRouteModel Model
|
||||
{
|
||||
get
|
||||
{
|
||||
return _model;
|
||||
}
|
||||
}
|
||||
|
||||
private Text Name;
|
||||
private Text Count;
|
||||
private Text Distance;
|
||||
private Text TotalClimb;
|
||||
private PFUIButton pFUIButton;
|
||||
private void Awake()
|
||||
{
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 40f, 0));
|
||||
this.GetComponent<Image>().material = material;
|
||||
|
||||
Name = this.transform.Find("Name").GetComponent<Text>();
|
||||
Count = this.transform.Find("Count").GetComponent<Text>();
|
||||
Distance = this.transform.Find("Distance").GetComponent<Text>();
|
||||
TotalClimb = this.transform.Find("TotalClimb").GetComponent<Text>();
|
||||
|
||||
pFUIButton = this.transform.Find("Ride").GetComponent<PFUIButton>();
|
||||
UIManager.AddEvent(pFUIButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) => {
|
||||
App.RouteIdParam = _model.Id;
|
||||
SceneManager.LoadScene("Ride");
|
||||
});
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
NearRouteModel _model;
|
||||
public void SetModel(NearRouteModel model)
|
||||
{
|
||||
if (this.isActiveAndEnabled)
|
||||
{
|
||||
if(_model.Id == model.Id)
|
||||
{
|
||||
//this.gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//this.gameObject.SetActive(true);
|
||||
_model = model;
|
||||
|
||||
Name.text = _model.Name;
|
||||
|
||||
Count.text = _model.TheHeat.ToString();
|
||||
Distance.text = _model.Distance.ToString("#.0")+"KM";
|
||||
TotalClimb.text = _model.TotalClimb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Show(Vector3 position, NearRouteModel model)
|
||||
{
|
||||
//if(position.y > position.z)
|
||||
//{
|
||||
// position.y = position.z;
|
||||
//}
|
||||
this.transform.position = position;
|
||||
|
||||
var localPosition = this.transform.localPosition;
|
||||
if (localPosition.y + 150 > localPosition.z)
|
||||
{
|
||||
localPosition.y = localPosition.z -150;
|
||||
}
|
||||
if(localPosition.x * -1f > localPosition.z)
|
||||
{
|
||||
localPosition.x = localPosition.z * -1f;
|
||||
}
|
||||
else if(localPosition.x > localPosition.z *2)
|
||||
{
|
||||
localPosition.x = localPosition.z * 2;
|
||||
}
|
||||
this.transform.localPosition = localPosition;
|
||||
this.transform.localScale = new Vector2(2, 2);
|
||||
this.SetModel(model);
|
||||
//tips.Show();
|
||||
this.gameObject.SetActive(true);
|
||||
}
|
||||
public void Hide()
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1614be1af0822445936f92435d0162b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,6 +7,7 @@ using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.UI.Control;
|
||||
|
||||
public class ConnectDeviceModal : PFUIPanel
|
||||
{
|
||||
@@ -26,6 +27,8 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
private Image Logo;
|
||||
private UnityEngine.Object deviceItem;
|
||||
private VerticalLayoutGroup content;
|
||||
private PFUIButton connectBtn;
|
||||
private Dictionary<ushort, DeviceItem> deviceList;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -36,8 +39,19 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
var container = this.transform.Find("GameObject");
|
||||
var closeBtn = container.Find("CloseBtn");
|
||||
Logo = container.Find("Logo").GetComponent<Image>();
|
||||
content = container.Find("Panel").Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
|
||||
var panel = container.Find("Panel");
|
||||
content = panel.Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
|
||||
|
||||
Material material = null;
|
||||
if (material == null)
|
||||
{
|
||||
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
}
|
||||
var rect = ((RectTransform)panel.transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 20f, 0));
|
||||
panel.GetComponent<Image>().material = material;
|
||||
|
||||
|
||||
UIManager.AddEvent(closeBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
//this.gameObject.SetActive(false);
|
||||
@@ -46,15 +60,39 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
|
||||
deviceItem = Resources.Load("UI/Prefab/Device/DeviceItem");
|
||||
|
||||
connectBtn = container.Find("ConnectBtn").GetComponent<PFUIButton>();
|
||||
|
||||
UIManager.AddEvent(connectBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
foreach (var item in deviceList)
|
||||
{
|
||||
if (item.Value.GetStatus() == false)
|
||||
{
|
||||
if (item.Value.DeviceInfo.Sensor == SensorType)
|
||||
{
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
var dd = deviceList.Select(d => d.Value).Where(d => d.GetStatus()).FirstOrDefault();
|
||||
if(dd != null)
|
||||
{
|
||||
dd.DeviceInfo.Connect();
|
||||
}
|
||||
this.Close();
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
protected override void Start()
|
||||
{
|
||||
SearchDevice();
|
||||
|
||||
}
|
||||
|
||||
private Dictionary<ushort, DeviceItem> deviceList;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
@@ -101,34 +139,38 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
if (deviceList.ContainsKey(device.DeviceNumber))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var gameObject = (GameObject)Instantiate(deviceItem);
|
||||
gameObject.transform.SetParent(content.transform);
|
||||
var deviceItemObj = gameObject.GetComponent<DeviceItem>();
|
||||
deviceItemObj.DeviceInfo = device;
|
||||
|
||||
|
||||
UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
//deviceItemObj.Select();
|
||||
if(deviceItemObj.DeviceInfo.Sensor == SensorType)
|
||||
{
|
||||
deviceItemObj.DeviceInfo.Connect();
|
||||
}
|
||||
////deviceItemObj.Select();
|
||||
//if(deviceItemObj.DeviceInfo.Sensor == SensorType)
|
||||
//{
|
||||
// deviceItemObj.DeviceInfo.Connect();
|
||||
//}
|
||||
deviceItemObj.Set(true);
|
||||
foreach (var item in deviceList)
|
||||
{
|
||||
if(item.Key != deviceItemObj.DeviceInfo.DeviceNumber)
|
||||
if (item.Key != deviceItemObj.DeviceInfo.DeviceNumber)
|
||||
{
|
||||
item.Value.Set(false);
|
||||
if(item.Value.DeviceInfo.Sensor == SensorType)
|
||||
{
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
}
|
||||
//if (item.Value.DeviceInfo.Sensor == SensorType)
|
||||
//{
|
||||
// item.Value.DeviceInfo.Disconnect();
|
||||
//}
|
||||
}
|
||||
}
|
||||
Close();
|
||||
//Close();
|
||||
}));
|
||||
|
||||
|
||||
|
||||
//UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
//{
|
||||
// //Debug.Log("de select");
|
||||
@@ -141,11 +183,22 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
deviceList.Add(device.DeviceNumber, deviceItemObj);
|
||||
}
|
||||
|
||||
var firstDevice = deviceList.Select(d => d.Value).Where(d => d.DeviceInfo.State == DeviceState.Connected).OrderByDescending(d => d.DeviceInfo.Priority).FirstOrDefault();
|
||||
if(firstDevice != null)
|
||||
if(deviceList.All(d=>d.Value.GetStatus() == false))
|
||||
{
|
||||
firstDevice.Set(true);
|
||||
var firstDevice = deviceList.Select(d => d.Value).Where(d => d.DeviceInfo.State == DeviceState.Connected).OrderByDescending(d => d.DeviceInfo.Priority).FirstOrDefault();
|
||||
if (firstDevice != null)
|
||||
{
|
||||
firstDevice.Set(true);
|
||||
|
||||
//connectBtn.text.text = "DISCOUNECT";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
base.Close();
|
||||
DestroyImmediate(this.gameObject);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
{
|
||||
shadow = mText.gameObject.AddComponent<Shadow>();
|
||||
}
|
||||
|
||||
shadow.enabled = true;
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color color1);
|
||||
shadow.effectColor = color1;
|
||||
}
|
||||
@@ -81,7 +81,10 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
//this.Select();
|
||||
//DeviceInfo.Connect();
|
||||
}
|
||||
|
||||
public bool GetStatus()
|
||||
{
|
||||
return this.isOn;
|
||||
}
|
||||
|
||||
public void Set(bool value)
|
||||
{
|
||||
@@ -98,6 +101,12 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
|
||||
else
|
||||
{
|
||||
mText.color = Color.white;
|
||||
var shadow = mText.gameObject.GetComponent<Shadow>();
|
||||
if (shadow != null)
|
||||
{
|
||||
//shadow = mText.gameObject.AddComponent<Shadow>();
|
||||
shadow.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,21 @@ using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.UI.UIEffect;
|
||||
using Assets.Scripts;
|
||||
|
||||
public class DeviceView : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string mType;
|
||||
private SensorType mType;
|
||||
|
||||
private SensorType SensorType
|
||||
{
|
||||
get
|
||||
{
|
||||
//Debug.Log(mType);
|
||||
Enum.TryParse(mType, out SensorType sensorType);
|
||||
return sensorType;
|
||||
//Enum.TryParse(mType, out SensorType sensorType);
|
||||
return mType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +36,9 @@ public class DeviceView : MonoBehaviour
|
||||
private Text title;
|
||||
private Text noDevice;
|
||||
private Text powerValue;
|
||||
private Text cadenceValue;
|
||||
private Text speedValue;
|
||||
private Text heartRateValue;
|
||||
//private Text cadenceValue;
|
||||
//private Text speedValue;
|
||||
//private Text heartRateValue;
|
||||
private Image logo;
|
||||
/// <summary>
|
||||
/// 没有设备的logo
|
||||
@@ -61,33 +63,64 @@ public class DeviceView : MonoBehaviour
|
||||
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
|
||||
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
|
||||
mPairButton.SetActive(false);
|
||||
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
|
||||
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.2f, 0));
|
||||
//this.GetComponent<Image>().material = material;
|
||||
var img1 = unconnectionPanel.GetComponent<Image>();
|
||||
if(img1 != null)
|
||||
{
|
||||
img1.material = material;
|
||||
|
||||
var gradient = unconnectionPanel.GetComponent<UIGradient>();
|
||||
if (gradient != null)
|
||||
{
|
||||
gradient.color1 = Utils.HexToColor("353543");
|
||||
gradient.color2 = Utils.HexToColor("23232D");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var img2 = connectionPanel.GetComponent<Image>();
|
||||
if(img2 != null)
|
||||
{
|
||||
img2.material = material;
|
||||
|
||||
var gradient1 = connectionPanel.GetComponent<UIGradient>();
|
||||
if (gradient1 != null)
|
||||
{
|
||||
gradient1.color1 = Utils.HexToColor("FF7485");
|
||||
gradient1.color2 = Utils.HexToColor("F93086");
|
||||
}
|
||||
}
|
||||
|
||||
logo = this.transform.Find("Logo").GetComponent<Image>();
|
||||
InitLogo();
|
||||
|
||||
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
|
||||
|
||||
mDisconnectButton = connectionPanel.transform.Find("DisconnectBtn").gameObject;
|
||||
var powerValueObj = connectionPanel.transform.Find("PowerValue");
|
||||
if(powerValueObj != null)
|
||||
{
|
||||
powerValue = powerValueObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
var cadenceValueObj = connectionPanel.transform.Find("CadenceValue");
|
||||
if (cadenceValueObj != null) {
|
||||
cadenceValue = cadenceValueObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
var speedValueObj = connectionPanel.transform.Find("SpeedValue");
|
||||
if (speedValueObj != null)
|
||||
{
|
||||
speedValue = speedValueObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
//var cadenceValueObj = connectionPanel.transform.Find("CadenceValue");
|
||||
//if (cadenceValueObj != null) {
|
||||
// cadenceValue = cadenceValueObj.gameObject.GetComponent<Text>();
|
||||
//}
|
||||
//var speedValueObj = connectionPanel.transform.Find("SpeedValue");
|
||||
//if (speedValueObj != null)
|
||||
//{
|
||||
// speedValue = speedValueObj.gameObject.GetComponent<Text>();
|
||||
//}
|
||||
|
||||
var heartRateValueObj = connectionPanel.transform.Find("HeartRateValue");
|
||||
if(heartRateValueObj != null)
|
||||
{
|
||||
heartRateValue = heartRateValueObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
//var heartRateValueObj = connectionPanel.transform.Find("HeartRateValue");
|
||||
//if(heartRateValueObj != null)
|
||||
//{
|
||||
// heartRateValue = heartRateValueObj.gameObject.GetComponent<Text>();
|
||||
//}
|
||||
|
||||
connectionPanel.SetActive(false);
|
||||
|
||||
@@ -251,10 +284,11 @@ public class DeviceView : MonoBehaviour
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.Cadence:
|
||||
cadenceValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
//cadenceValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
powerValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
break;
|
||||
case SensorType.HeartRate:
|
||||
heartRateValue.text = (connectedDevice as IHeartRateDevice).HeartRate.ToString();
|
||||
powerValue.text = (connectedDevice as IHeartRateDevice).HeartRate.ToString();
|
||||
break;
|
||||
case SensorType.Power:
|
||||
powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
|
||||
@@ -262,10 +296,10 @@ public class DeviceView : MonoBehaviour
|
||||
case SensorType.Speed:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
speedValue.text = (connectedDevice as ISpeedDevice).Speed.ToString();
|
||||
powerValue.text = (connectedDevice as ISpeedDevice).Speed.ToString();
|
||||
break;
|
||||
case SensorType.Trainer:
|
||||
powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
|
||||
//powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
|
||||
//cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
//speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString();
|
||||
break;
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace Assets.Scripts.UI.Prefab.Login
|
||||
}
|
||||
return op.options;
|
||||
}
|
||||
public static List<Dropdown.OptionData> dayOption28 = SetOptions(28);
|
||||
public static List<Dropdown.OptionData> dayOption29 = SetOptions(29);
|
||||
public static List<Dropdown.OptionData> dayOption30 = SetOptions(30);
|
||||
public static List<Dropdown.OptionData> dayOption31 = SetOptions(31);
|
||||
public static Dictionary<int, List<Dropdown.OptionData>> dayOption = new Dictionary<int, List<Dropdown.OptionData>>()
|
||||
{
|
||||
{28,SetOptions(28) },{29,SetOptions(29) },{30,SetOptions(30) },{31,SetOptions(31) }
|
||||
};
|
||||
}
|
||||
public class CountryModel
|
||||
{
|
||||
@@ -76,22 +76,8 @@ namespace Assets.Scripts.UI.Prefab.Login
|
||||
}
|
||||
public List<Dropdown.OptionData> GetDayOptions(int year,int month)
|
||||
{
|
||||
if (new int[] { 1, 3, 5, 7, 8, 10, 12 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption31;
|
||||
}
|
||||
else if (new int[] { 4, 6, 9, 11 }.Contains(month))
|
||||
{
|
||||
return DayOptions.dayOption30;
|
||||
}
|
||||
else if (month == 2)
|
||||
{
|
||||
return DateTime.IsLeapYear(year) ? DayOptions.dayOption29 : DayOptions.dayOption28;
|
||||
}
|
||||
else
|
||||
{
|
||||
return days;
|
||||
}
|
||||
int day = DateTime.DaysInMonth(year, month);
|
||||
return DayOptions.dayOption[day];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,16 +20,17 @@ public class QuickLoginUser : MonoBehaviour
|
||||
}
|
||||
public void Initial(QUserInfo user)
|
||||
{
|
||||
if (user ==null) return;
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
if (user == null) return;
|
||||
transform.GetComponent<Button>().onClick.AddListener(async () =>
|
||||
{
|
||||
ApiBase.SetCookie(user.Cookie);
|
||||
var r = ConfigHelper.userApi.GetUserInfo();
|
||||
var r = await ConfigHelper.userApi.QuickLogin();
|
||||
if (r.result)
|
||||
{
|
||||
App.CurrentUser = r.data;
|
||||
//ConfigHelper.CurrentUser = r.data.Value<UserResultModel>("user");
|
||||
//ConfigHelper.CurrentUser = re;
|
||||
var usermodel = r.data.Value<JObject>("user");
|
||||
//var usermodel = r.data.Value<JObject>("user");
|
||||
//App.CurrentUser = new UserModel
|
||||
//{
|
||||
// NickName = usermodel.Value<string>("NickName"),
|
||||
@@ -41,6 +42,7 @@ public class QuickLoginUser : MonoBehaviour
|
||||
// Distance = 0,
|
||||
// Climb = "",
|
||||
//};
|
||||
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
else
|
||||
@@ -94,6 +96,7 @@ public class QuickLoginUser : MonoBehaviour
|
||||
transform.Find("Avatar").GetComponent<RawImage>().DOFade(1f, 0.3f);
|
||||
transform.GetComponent<Button>().enabled = true;
|
||||
transform.Find("NickNameText").GetComponent<Text>().enabled = true;
|
||||
transform.Find("BtnDelete").GetComponent<Button>().gameObject.SetActive(true);
|
||||
}
|
||||
public void setNoActive()
|
||||
{
|
||||
@@ -102,5 +105,6 @@ public class QuickLoginUser : MonoBehaviour
|
||||
transform.Find("Avatar").GetComponent<RawImage>().DOFade(0.5f, 0.3f);
|
||||
transform.GetComponent<Button>().enabled = false;
|
||||
transform.Find("NickNameText").GetComponent<Text>().enabled = false;
|
||||
transform.Find("BtnDelete").GetComponent<Button>().gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MainNav : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
|
||||
var rect = ((RectTransform)this.transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
this.GetComponent<Image>().material = material;
|
||||
|
||||
var wifi = this.transform.Find("Wifi");
|
||||
UIManager.AddEvent(wifi.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
Debug.Log("click wifi");
|
||||
UIManager.ShowDevicePanel();
|
||||
});
|
||||
|
||||
var home = this.transform.Find("Home");
|
||||
UIManager.AddEvent(home.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
});
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71aaed8b61d057e4a87864a667ca1486
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.Prefab.MapList
|
||||
{
|
||||
public class MapFilterOptions
|
||||
{
|
||||
public static List<Dropdown.OptionData> distances = new string[] {"全部",
|
||||
"0-5KM",
|
||||
"5-10KM",
|
||||
"10-20KM",
|
||||
"20-30KM",
|
||||
"30-50KM",
|
||||
"50-100KM",
|
||||
"100-200KM",
|
||||
"200-无限制", }.Select(x=>new Dropdown.OptionData(x)).ToList();
|
||||
public static Dictionary<string, string> distanceDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"全部","" },
|
||||
{"0-5KM","0-5" },
|
||||
{"5-10KM","5-10" },
|
||||
{"10-20KM","10-20" },
|
||||
{"20-30KM","20-30" },
|
||||
{"50-100KM","50-100" },
|
||||
{"100-200KM","100-200" },
|
||||
{"200-无限制","200-99999" },
|
||||
};
|
||||
public static Dictionary<string,string> diffDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"FLAT","0-100" },
|
||||
{"LV.4","100-250" },
|
||||
{"LV.3","250-350" },
|
||||
{"LV.2","350-550" },
|
||||
{"LV.1","550-750" },
|
||||
{"HC","750-99999" },
|
||||
};
|
||||
public static List<Dropdown.OptionData> sorts = new string[] {
|
||||
"Distance","Name","Difficulty","Hot"//,"Times"
|
||||
}.Select(x => new Dropdown.OptionData(x)).ToList();
|
||||
public static Dictionary<string, string> diffDisplayDict = new Dictionary<string, string>()
|
||||
{
|
||||
{"FLAT","0-100" },
|
||||
{"LV.4","100-250" },
|
||||
{"LV.3","250-350" },
|
||||
{"LV.2","350-550" },
|
||||
{"LV.1","550-750" },
|
||||
{"HC","750-99999" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 045d47b55ae6eb844827ba951f3af3e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.Cyp.Common;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -6,12 +6,6 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MyMap
|
||||
{
|
||||
public string name { get; set; }
|
||||
public int rank { get; set; }
|
||||
public string image { get; set; }
|
||||
}
|
||||
public class MapItem : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
@@ -36,9 +30,15 @@ public class MapItem : MonoBehaviour
|
||||
});
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
Utils.DisplayImage(StartCoroutine, transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage);
|
||||
var props = transform.Find("Props");
|
||||
transform.Find("CollectImg").gameObject.SetActive(myMap.IsFavorite);
|
||||
var props = transform.Find("Props");
|
||||
props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString("#0.00")}KM";
|
||||
props.Find("EleText").GetComponent<Text>().text = $"{(myMap.TotalClimb ?? 0.0).ToString("#0.00")}M";
|
||||
props.Find("SlopeText").GetComponent<Text>().text = $"{myMap.AverageGrade.ToString("#0.00")}%";
|
||||
props.Find("rideText").GetComponent<Text>().text = myMap.TheHeat.ToString();
|
||||
var tabContainer = transform.Find("TabContainer");
|
||||
var diff = tabContainer.Find("Diff");
|
||||
diff.Find("Text").GetComponent<Text>().text = myMap.Hard;
|
||||
tabContainer.Find("3d").gameObject.SetActive(myMap.Enable3D);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MapController : MonoBehaviour
|
||||
public class RotateBg : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -13,6 +13,6 @@ public class MapController : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
transform.Rotate(new Vector3(0,0,-0.01f*1/3));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2646b2ba277320e41bea125e9aebcb06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,441 @@
|
||||
using Assets.Scripts.Apis;
|
||||
using Mapbox.Unity.Map;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Mapbox.Unity.MeshGeneration.Data;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Assets.Scripts;
|
||||
using Mapbox.Utils;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Mapbox.Examples;
|
||||
|
||||
public class BigMapController : PFUIPanel
|
||||
{
|
||||
MapApi mapApi;
|
||||
MapBoxApi mapboxApi;
|
||||
AbstractMap mapManager;
|
||||
//GameObject cube;
|
||||
//GameObject cube1;
|
||||
GameObject canvas;
|
||||
GameObject content;
|
||||
Text keyword;
|
||||
UnityEngine.Object begin;
|
||||
Sprite end;
|
||||
private Dictionary<int, LineItem> linesCache = new Dictionary<int, LineItem>();
|
||||
Tips tips;
|
||||
int timer = 0;
|
||||
protected override void Awake()
|
||||
{
|
||||
mapApi = new MapApi();
|
||||
mapboxApi = new MapBoxApi();
|
||||
|
||||
begin = Resources.Load("UI/Prefab/BigMap/Begin");
|
||||
|
||||
mapManager = this.transform.Find("Map").GetComponent<AbstractMap>();
|
||||
mapManager.OnInitialized += MapManager_OnInitialized;
|
||||
mapManager.OnUpdated += MapManager_OnUpdated;
|
||||
mapManager.OnMapRedrawn += () =>
|
||||
{
|
||||
//Debug.Log("map redrawn");
|
||||
};
|
||||
mapManager.OnTileFinished += (e) =>
|
||||
{
|
||||
//Debug.Log("finished");
|
||||
};
|
||||
|
||||
//// mapManager.OnTileFinished += MapManager_OnTileFinished;
|
||||
//mapManager.SetZoom(13);
|
||||
//mapManager.SetCenterLatitudeLongitude(new Mapbox.Utils.Vector2d(32.051203, 118.771572));
|
||||
|
||||
this.transform.Find("Map").GetComponent<QuadTreeCameraMovement>()._referenceCamera = Camera.main;
|
||||
|
||||
canvas = this.transform.Find("Canvas").gameObject;
|
||||
canvas.GetComponent<Canvas>().worldCamera = Camera.main;
|
||||
var goList = canvas.transform.Find("GoList");
|
||||
UIManager.AddEvent(goList.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
//App.MainSceneParam.Add("Name", "MapListPanel");
|
||||
//SceneManager.LoadScene("MainScene");
|
||||
|
||||
mapManager.Destroy();
|
||||
|
||||
UIManager.ShowMapListPanel();
|
||||
|
||||
//this.gameObject.SetActive(false);
|
||||
DestroyImmediate(this.gameObject);
|
||||
});
|
||||
|
||||
var panel = canvas.transform.Find("Panel");
|
||||
SetRounded(panel,30f);
|
||||
|
||||
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
|
||||
var input = panel.Find("InputField");
|
||||
SetRounded(input, 20f);
|
||||
keyword = input.Find("Text").GetComponent<Text>();
|
||||
var searchBtn = input.Find("Search").gameObject;
|
||||
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
|
||||
|
||||
tips = ((GameObject)Instantiate(Resources.Load("UI/Prefab/BigMap/Tips"), canvas.transform.Find("TipsContainer"))).GetComponent<Tips>();
|
||||
tips.Hide();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给对象设置圆角
|
||||
/// </summary>
|
||||
/// <param name="panel"></param>
|
||||
/// <param name="radius"></param>
|
||||
void SetRounded(Transform panel, float radius)
|
||||
{
|
||||
var rounded = Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial");
|
||||
var material = Instantiate(rounded);
|
||||
var rect = ((RectTransform)panel).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, radius, 0));
|
||||
panel.GetComponent<Image>().material = material;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
//var mapObject = this.transform.Find("Map");
|
||||
|
||||
}
|
||||
|
||||
private void Search(BaseEventData e)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(keyword.text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var infoStr = mapboxApi.GetAddressInfo(keyword.text);
|
||||
//Debug.Log(info);
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
private void MapManager_OnInitialized()
|
||||
{
|
||||
Load();
|
||||
}
|
||||
private void MapManager_OnUpdated()
|
||||
{
|
||||
foreach (var item in linesCache)
|
||||
{
|
||||
//if(item.Value.LineObject != null)
|
||||
//{
|
||||
// item.Value.LineObject.Destroy();
|
||||
// item.Value.LineObject = null;
|
||||
//}
|
||||
//if(item.Value.BeginMarker != null)
|
||||
//{
|
||||
// item.Value.BeginMarker.Destroy();
|
||||
// item.Value.BeginMarker = null;
|
||||
//}
|
||||
CreateLine(item.Key, item.Value);
|
||||
}
|
||||
timer += 1;
|
||||
Invoke("Load", 0.3f);
|
||||
//Load();
|
||||
}
|
||||
|
||||
async void Load()
|
||||
{
|
||||
if (timer >1)
|
||||
{
|
||||
timer--;
|
||||
return;
|
||||
}
|
||||
timer = 0;
|
||||
|
||||
var s1 = Camera.main.ScreenToWorldPoint(new Vector3(340f, 0f, 180f));
|
||||
//Debug.Log(s1);
|
||||
var start = mapManager.WorldToGeoPosition(s1);
|
||||
//Debug.Log(start);
|
||||
|
||||
var worldPoint = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 180f));
|
||||
var end = mapManager.WorldToGeoPosition(worldPoint);
|
||||
//cube.transform.position = worldPoint;
|
||||
//cube1.transform.position = s1;
|
||||
//Debug.Log(end);
|
||||
//Screen.width
|
||||
//map.WorldToGeoPosition(start)
|
||||
|
||||
var bounds = $"{ start.y },{ start.x };{ end.y },{ end.x }";
|
||||
var res = await mapApi.GetNearRouteAsync((float)mapManager.CenterLatitudeLongitude.x, (float)mapManager.CenterLatitudeLongitude.y,
|
||||
mapManager.Zoom, bounds);
|
||||
if(res.result == false)
|
||||
{
|
||||
Debug.LogError(res.errMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
//Debug.Log("条数:"+res.data.Count);
|
||||
|
||||
var lines = await mapApi.GetDetailsAsync(res.data.Select(d => d.Id).ToArray());
|
||||
|
||||
var aa = Newtonsoft.Json.Linq.JObject.Parse(lines);
|
||||
|
||||
//var points = (aa["data"] as JArray).First()["Points"] as JArray;
|
||||
|
||||
var ids = new List<int>();
|
||||
foreach (var line in (aa["data"] as JArray))
|
||||
{
|
||||
var id = line.Value<int>("Id");
|
||||
ids.Add(id);
|
||||
var points = line["Points"] as JArray;
|
||||
|
||||
if (linesCache.ContainsKey(id))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var pp1 = new List<Vector2d>();
|
||||
foreach (var item in points)
|
||||
{
|
||||
pp1.Add(new Mapbox.Utils.Vector2d(item[0].ToObject<double>(), item[1].ToObject<double>()));
|
||||
}
|
||||
|
||||
if (!linesCache.ContainsKey(id))
|
||||
{
|
||||
linesCache.Add(id, new LineItem { Points = pp1, Model = res.data.Single(d=>d.Id == id) });
|
||||
}
|
||||
CreateLine(id, linesCache[id]);
|
||||
|
||||
//Load();
|
||||
}
|
||||
|
||||
foreach (var item in linesCache.ToList())
|
||||
{
|
||||
if(ids.All(id=>id != item.Key))
|
||||
{
|
||||
item.Value.Destroy();
|
||||
linesCache.Remove(item.Key);
|
||||
if(item.Value.Selected)
|
||||
{
|
||||
tips.Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//GameObject direct;
|
||||
void CreateLine(int id, LineItem line)
|
||||
{
|
||||
#region 画线
|
||||
List<Vector2d> pp1 = line.Points;
|
||||
var dat = new List<Vector3>();
|
||||
foreach (var item in pp1)
|
||||
{
|
||||
var pp = mapManager.GeoToWorldPosition(item);
|
||||
pp.y += 0.3f;
|
||||
dat.Add(pp);
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
|
||||
var direct = line.LineObject;
|
||||
LineRenderer lineRender;
|
||||
if (direct == null)
|
||||
{
|
||||
direct = new GameObject($"MapRoute-{ id }");
|
||||
direct.transform.SetParent(this.transform);
|
||||
lineRender = direct.AddComponent<LineRenderer>();
|
||||
lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
line.LineObject = direct;
|
||||
|
||||
lineRender.startColor = lineRender.endColor = Utils.HexToColor("F93086");
|
||||
|
||||
//设置宽度
|
||||
lineRender.startWidth = 1.2f;
|
||||
lineRender.endWidth = 1.2f;
|
||||
lineRender.numCornerVertices = 90;
|
||||
}
|
||||
else
|
||||
{
|
||||
lineRender = direct.GetComponent<LineRenderer>();
|
||||
}
|
||||
|
||||
//lineRender.SetWidth(0.5f, 0.5f);
|
||||
lineRender.positionCount = dat.Count;
|
||||
//lineRender.SetVertexCount(dat.Count);
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
|
||||
#endregion
|
||||
|
||||
#region 添加左边的列表项
|
||||
if (linesCache[id].Item == null)
|
||||
{
|
||||
var itemObject = Resources.Load("UI/Prefab/BigMap/Item");
|
||||
|
||||
var itemObject1 = (GameObject)Instantiate(itemObject, content.transform, false);
|
||||
var iii = itemObject1.GetComponent<Item>();
|
||||
iii.SetModel(line.Model);
|
||||
|
||||
line.Item = iii;
|
||||
iii.onClick = () =>
|
||||
{
|
||||
if (line.Selected)
|
||||
{
|
||||
line.Selected = false;
|
||||
tips.Hide();
|
||||
//iii.Selected(false);
|
||||
return;
|
||||
}
|
||||
line.Selected = true;
|
||||
//iii.Selected(true);
|
||||
var position = line.BeginMarker.transform.position;
|
||||
//position.z += 25;
|
||||
tips.Show(position, line.Model);
|
||||
|
||||
foreach (var item in linesCache)
|
||||
{
|
||||
if(item.Key != line.Model.Id)
|
||||
{
|
||||
item.Value.Selected = false;
|
||||
//item.Value.Item.Selected(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 添加marker
|
||||
|
||||
if (line.BeginMarker == null)
|
||||
{
|
||||
var beginInstance = (GameObject)Instantiate(begin, canvas.transform.Find("MarkerContainer").transform);
|
||||
line.BeginMarker = beginInstance;
|
||||
|
||||
|
||||
UIManager.AddEvent(line.BeginMarker, EventTriggerType.PointerClick, new UnityAction<BaseEventData>((e) =>
|
||||
{
|
||||
if (line.Selected)
|
||||
{
|
||||
line.Selected = false;
|
||||
tips.Hide();
|
||||
return;
|
||||
}
|
||||
line.Selected = true;
|
||||
|
||||
var position = line.BeginMarker.transform.position;
|
||||
//position.z += 25;
|
||||
tips.Show(position, line.Model);
|
||||
|
||||
foreach (var item in linesCache)
|
||||
{
|
||||
if (item.Key != line.Model.Id)
|
||||
{
|
||||
item.Value.Selected = false;
|
||||
//item.Value.Item.Selected(false);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
line.BeginMarker.transform.localScale = new Vector3(2,2);
|
||||
//beginInstance.transform.localRotation = new Quaternion(90,0,0,0);
|
||||
|
||||
line.BeginMarker.transform.position = ConverToPosition(line.Points.First());
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
if (line.Selected)
|
||||
{
|
||||
line.Selected = true;
|
||||
var position = line.BeginMarker.transform.position;
|
||||
//position.z += 25;
|
||||
tips.Show(position, line.Model);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 转换地理坐标到屏幕坐标
|
||||
/// </summary>
|
||||
/// <param name="vector"></param>
|
||||
/// <returns></returns>
|
||||
Vector3 ConverToPosition(Vector2d vector)
|
||||
{
|
||||
var worldPosition = mapManager.GeoToWorldPosition(vector);//32.061255, 118.80925
|
||||
|
||||
var vp = Camera.main.WorldToViewportPoint(worldPosition);
|
||||
vp.z = 180f;
|
||||
////Debug.Log(vp);
|
||||
//var wd = Camera.main.WorldToScreenPoint(worldPosition);
|
||||
var wd = Camera.main.ViewportToWorldPoint(vp);
|
||||
return wd;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//Debug.Log(Input.mousePosition.x + "," + Input.mousePosition.y + "," + Input.mousePosition.z);
|
||||
//timer += Time.deltaTime;
|
||||
}
|
||||
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
//base.Close();
|
||||
|
||||
DestroyImmediate(this.gameObject);
|
||||
}
|
||||
|
||||
class LineItem
|
||||
{
|
||||
public List<Vector2d> Points { get; set; }
|
||||
|
||||
public GameObject LineObject { get; set; }
|
||||
|
||||
public GameObject BeginMarker { get; set; }
|
||||
|
||||
public NearRouteModel Model { get; set; }
|
||||
|
||||
public Item Item { get; set; }
|
||||
|
||||
private bool _Selected = false;
|
||||
public bool Selected {
|
||||
get
|
||||
{
|
||||
return _Selected;
|
||||
}
|
||||
set
|
||||
{
|
||||
_Selected = value;
|
||||
Item.Selected(value);
|
||||
var lineRender = LineObject.GetComponent<LineRenderer>();
|
||||
if (value)
|
||||
{
|
||||
lineRender.startColor = lineRender.endColor = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
lineRender.startColor = lineRender.endColor = Utils.HexToColor("F93086");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
//Debug.Log($"销毁{ item.Key }, { item.Value.Item != null }");
|
||||
LineObject.Destroy();
|
||||
BeginMarker.Destroy();
|
||||
Item.gameObject.Destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 221b4141e3d502548ac3b7fe1b3245d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,7 +17,10 @@ public class DeviceController : PFUIPanel
|
||||
private Sprite ant1;
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
AntConnector.Instance();
|
||||
|
||||
Debug.Log("device awake");
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
@@ -30,10 +33,11 @@ public class DeviceController : PFUIPanel
|
||||
// UIManager.ShowHomePanel();
|
||||
//});
|
||||
|
||||
mReturnBtn = this.transform.Find("ReturnBtn").GetComponent<Button>();
|
||||
mReturnBtn = this.transform.Find("CloseBtn").GetComponent<Button>();
|
||||
UIManager.AddEvent(mReturnBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
UIManager.ShowHomePanel();
|
||||
//UIManager.ShowHomePanel();
|
||||
UIManager.CloseModal();
|
||||
}));
|
||||
|
||||
var bg = this.transform.Find("Status").Find("Bg");
|
||||
@@ -41,7 +45,10 @@ public class DeviceController : PFUIPanel
|
||||
|
||||
ant0 = Resources.Load<Sprite>("Images/ANT+_0");
|
||||
ant1 = Resources.Load<Sprite>("Images/ANT+_1");
|
||||
|
||||
Debug.Log("device start");
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
|
||||
@@ -95,29 +95,29 @@ public class EditUserController : PFUIPanel
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
mHeadImage.material = material;
|
||||
|
||||
var currentUser = App.CurrentUser;
|
||||
mIdText.text = "ID:" + currentUser.Id.ToString();
|
||||
mNameText.text = currentUser.Nickname;
|
||||
//var currentUser = App.CurrentUser;
|
||||
//mIdText.text = "ID:" + currentUser.Id.ToString();
|
||||
//mNameText.text = currentUser.Nickname;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
}
|
||||
if (currentUser.Sex == 1)
|
||||
{
|
||||
mSexDropdown.SelectValue("男");
|
||||
}
|
||||
else
|
||||
{
|
||||
mSexDropdown.SelectValue("女");
|
||||
}
|
||||
if (currentUser.Birthday.HasValue)
|
||||
{
|
||||
var birthday = currentUser.Birthday.Value;
|
||||
mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
}
|
||||
//if (!string.IsNullOrWhiteSpace(currentUser.WxHeadImg))
|
||||
//{
|
||||
// Utils.DisplayImage(StartCoroutine, mHeadImage, currentUser.WxHeadImg);
|
||||
//}
|
||||
//if (currentUser.Sex == 1)
|
||||
//{
|
||||
// mSexDropdown.SelectValue("男");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// mSexDropdown.SelectValue("女");
|
||||
//}
|
||||
//if (currentUser.Birthday.HasValue)
|
||||
//{
|
||||
// var birthday = currentUser.Birthday.Value;
|
||||
// mYearDropdown.SelectValue(birthday.Year.ToString());
|
||||
// mMonthDropdown.SelectValue(birthday.Month.ToString());
|
||||
// mDayDropdown.SelectValue(birthday.Day.ToString());
|
||||
//}
|
||||
|
||||
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
@@ -35,35 +37,33 @@ public class HomeController : PFUIPanel
|
||||
// toast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
|
||||
// toast.transform.parent = parent;
|
||||
//}
|
||||
if (App.CurrentUser != null)
|
||||
{
|
||||
GetSummary();
|
||||
}
|
||||
|
||||
//if (More != null)
|
||||
//{
|
||||
// More.onClick.AddListener(MoreFunc);
|
||||
//}
|
||||
BtnRide.onClick.AddListener(GoRide);
|
||||
var wifi = this.transform.Find("MainToolContainer").Find("Wifi");
|
||||
UIManager.AddEvent(wifi.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
Debug.Log("click wifi");
|
||||
UIManager.ShowDevicePanel();
|
||||
});
|
||||
|
||||
var avatar = userInfo.Find("Avatar");
|
||||
var avatar = userInfo.Find("Avatar").GetComponent<RawImage>();
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)avatar.transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
avatar.material = material;
|
||||
|
||||
UIManager.AddEvent(avatar.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
|
||||
if (App.CurrentUser == null)
|
||||
UIManager.AddEvent(userInfo.Find("BtnMore").gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
Login();
|
||||
}
|
||||
UIManager.ShowAlert("test");
|
||||
});
|
||||
|
||||
GetSummary();
|
||||
}
|
||||
|
||||
private async void Login()
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await new UserApi().Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
@@ -91,31 +91,36 @@ public class HomeController : PFUIPanel
|
||||
|
||||
}
|
||||
|
||||
void SetCurrentUser()
|
||||
void SetCurrentUser(SummaryResultModel summary)
|
||||
{
|
||||
userInfo.Find("NickName").GetComponent<Text>().text = App.CurrentUser.Nickname;
|
||||
userInfo.Find("GroupTop").Find("FtpContainer").Find("FtpValue").GetComponent<Text>().text = App.CurrentUser.FTP.ToString();
|
||||
userInfo.Find("GroupTop").Find("WeightContainer").Find("WeightValue").GetComponent<Text>().text = App.CurrentUser.Weight.ToString();
|
||||
userInfo.Find("GroupTop").Find("WKGContainer").Find("WKGValue").GetComponent<Text>().text = $"{App.CurrentUser.Weight}kg/{App.CurrentUser.BicycleWeight}kg";
|
||||
//userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = App.CurrentUser.Carlories;
|
||||
//userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = App.CurrentUser.Distance.ToString("#0.00");
|
||||
//userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = App.CurrentUser.Climb;
|
||||
userInfo.Find("CaloriesContainer").Find("CaloriesValue").GetComponent<Text>().text = summary.Kcal;
|
||||
userInfo.Find("KMContainer").Find("KMValue").GetComponent<Text>().text = summary.TotalDistance.ToString();
|
||||
userInfo.Find("ClimbContainer").Find("ClimbValue").GetComponent<Text>().text = summary.TotalClimb;
|
||||
//var user = ConfigHelper.CurrentUser;
|
||||
//Ftp.text = user.FTP.ToString();
|
||||
//Ftp.text = summary.Ftp.ToString();
|
||||
//Weight.text = user.Weight.ToString();
|
||||
//WKG.text = $"{user.Weight}KG/{user.BicycleWeight}KG";
|
||||
//NickName.text = user.Nickname;
|
||||
//Utils.DisplayImage(StartCoroutine, userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.Avatar);
|
||||
Utils.DisplayImage(StartCoroutine, userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
|
||||
}
|
||||
void GetSummary()
|
||||
async void GetSummary()
|
||||
{
|
||||
if (App.CurrentUser == null)
|
||||
{
|
||||
await Login();
|
||||
}
|
||||
|
||||
var res = ConfigHelper.userApi.GetSummary();
|
||||
if (res.result)
|
||||
{
|
||||
//App.CurrentUser.Distance = res.data.TotalDistance;
|
||||
//App.CurrentUser.Climb = res.data.TotalClimb;
|
||||
//App.CurrentUser.Carlories = res.data.Kcal;
|
||||
SetCurrentUser();
|
||||
SetCurrentUser(res.data);
|
||||
//Climb.text = $"{res.data.TotalClimb.ToString()}M";
|
||||
//Calories.text = $"{res.data.Kcal.ToString()}KCAL";
|
||||
//Calories.text = res.data.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Assets.Cyp.Common;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Prefab.MapList;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -20,8 +21,17 @@ public class MapListController : PFUIPanel
|
||||
[HideInInspector] public int pageIndex = 0;
|
||||
[HideInInspector] public int pageSize = 20;
|
||||
[HideInInspector] public string hard = "全部";
|
||||
|
||||
private Transform distanceOptions;
|
||||
private Transform diffOptions;
|
||||
private Transform tdContainer;
|
||||
private Transform favContainer;
|
||||
private Transform sorts;
|
||||
private Transform sortDir;
|
||||
private Transform searchInput;
|
||||
//private Transform distanceOption;
|
||||
//private Transform distanceOption;
|
||||
private Button returnBtn;
|
||||
GameObject btnMapMode;
|
||||
public GameObject Content {
|
||||
get
|
||||
{
|
||||
@@ -35,6 +45,11 @@ public class MapListController : PFUIPanel
|
||||
//{
|
||||
// hardSelector.onValueChanged.AddListener(ChangeHard);
|
||||
//}
|
||||
btnMapMode = this.transform.Find("BtnMapMode").gameObject;
|
||||
UIManager.AddEvent(btnMapMode, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.ShowBigMapPanel();
|
||||
});
|
||||
if (content!=null)
|
||||
{
|
||||
//var transform = content.transform.GetComponent<RectTransform>();
|
||||
@@ -45,6 +60,44 @@ public class MapListController : PFUIPanel
|
||||
// layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
|
||||
//}
|
||||
}
|
||||
distanceOptions = transform.Find("Panel").Find("Panel").Find("distanceOptions");
|
||||
if (distanceOptions != null)
|
||||
{
|
||||
var dDropdown = distanceOptions.GetComponent<Dropdown>();
|
||||
dDropdown.options = MapFilterOptions.distances;
|
||||
dDropdown.onValueChanged.AddListener(ChangeDistance);
|
||||
}
|
||||
diffOptions = transform.Find("Panel").Find("Panel").Find("DifficultyContainer");
|
||||
if (diffOptions != null)
|
||||
{
|
||||
foreach (Transform t in diffOptions)
|
||||
{
|
||||
var button = t.GetComponent<Button>();
|
||||
var image = t.GetComponent<Image>();
|
||||
var text = t.Find("Text").GetComponent<Text>();
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#23232D", out Color c1);
|
||||
if (image.color.r == c1.r && image.color.g == c1.g && image.color.b == c1.b)
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#F93086", out Color c);
|
||||
image.color = c;
|
||||
text.color = new Color(1, 1, 1,1);
|
||||
hands.Add(MapFilterOptions.diffDict[text.text]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#6E6E7D", out Color c);
|
||||
image.color = c1;
|
||||
text.color = c;
|
||||
hands.Remove(MapFilterOptions.diffDict[text.text]);
|
||||
}
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
GetList();
|
||||
if (scroll != null)
|
||||
{
|
||||
@@ -63,6 +116,73 @@ public class MapListController : PFUIPanel
|
||||
UIManager.ShowHomePanel();
|
||||
});
|
||||
}
|
||||
tdContainer = transform.Find("Panel").Find("Panel").Find("3dContainer");
|
||||
favContainer = transform.Find("Panel").Find("Panel").Find("FavContainer");
|
||||
if (tdContainer != null)
|
||||
{
|
||||
tdContainer.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
var gou = tdContainer.Find("Gou").gameObject;
|
||||
bool v = !gou.activeSelf;
|
||||
gou.SetActive(v);
|
||||
is3d = v;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
if (favContainer != null)
|
||||
{
|
||||
favContainer.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
var gou = favContainer.Find("Gou").gameObject;
|
||||
bool v = !gou.activeSelf;
|
||||
gou.SetActive(v);
|
||||
isFav = v;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
searchInput = transform.Find("Panel").Find("Panel").Find("SearchInput");
|
||||
if (searchInput != null)
|
||||
{
|
||||
searchInput.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
ftname = searchInput.GetComponent<InputField>().text;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
sorts = transform.Find("Panel").Find("Panel").Find("FilterOptions");
|
||||
if (sorts != null)
|
||||
{
|
||||
var drop = sorts.GetComponent<Dropdown>();
|
||||
drop.options = MapFilterOptions.sorts;
|
||||
drop.value = 3;
|
||||
drop.onValueChanged.AddListener((int index)=>
|
||||
{
|
||||
sort = drop.options[index].text;
|
||||
var image = sortDir.Find("Image").GetComponent<Image>();
|
||||
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
||||
sortDire = "desc";
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
sortDir = transform.Find("Panel").Find("Panel").Find("Dir");
|
||||
if (sortDir)
|
||||
{
|
||||
var image = sortDir.Find("Image").GetComponent<Image>();
|
||||
sortDir.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
if (image.sprite.name == "DOWN")
|
||||
{
|
||||
image.sprite = Resources.Load<Sprite>("Images/UP");
|
||||
sortDire = "asc";
|
||||
}
|
||||
else
|
||||
{
|
||||
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
||||
sortDire = "desc";
|
||||
}
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
@@ -73,7 +193,6 @@ public class MapListController : PFUIPanel
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
pageIndex++;
|
||||
GetList();
|
||||
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= 1)
|
||||
{
|
||||
@@ -81,28 +200,39 @@ public class MapListController : PFUIPanel
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeHard(int index)
|
||||
private void ChangeDistance(int index)
|
||||
{
|
||||
var text = distanceOptions.GetComponent<Dropdown>().options[index].text;
|
||||
distance = MapFilterOptions.distanceDict[text];
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
//var text = hardSelector.options[index].text;
|
||||
//if (text == "全部难度")
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
//查询条件
|
||||
string ftname = "";
|
||||
string distance = "";
|
||||
List<string> hands = new List<string>();
|
||||
bool is3d = false,isFav = false;
|
||||
string sort = "Hot",sortDire = "desc";
|
||||
//string name = "";
|
||||
//string name = "";
|
||||
public void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = Global.mapApi.GetList(pageIndex, pageSize, "");
|
||||
var res = ConfigHelper.mapApi.GetList(pageIndex, pageSize, ftname,distance,string.Join(",",hands),is3d,sort,sortDire,isFav);
|
||||
if (res.result)
|
||||
{
|
||||
|
||||
if (res.data.Count == 0)
|
||||
if (res.data.Count == 0 && pageIndex != 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = false;
|
||||
DisplayMaps(res.data);
|
||||
}
|
||||
}
|
||||
@@ -128,6 +258,13 @@ public class MapListController : PFUIPanel
|
||||
pageIndex = 0;
|
||||
GetList();
|
||||
}
|
||||
void ResetList()
|
||||
{
|
||||
distance = "";
|
||||
hands = new List<string>();
|
||||
name = "";
|
||||
Refresh();
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d3acfe11364023479f5bbb56d2cabde
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,216 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ResultListController : MonoBehaviour
|
||||
{
|
||||
[SerializeField]Transform routeResult;
|
||||
Transform scrollContent;
|
||||
Transform routeScroll, matchScroll;
|
||||
Transform routeContent, matchContent;
|
||||
Transform btnRoute, btnMatch,searchInput;
|
||||
Color c1, c2;
|
||||
// Start is called before the first frame update
|
||||
int pageIndex = 0, pageSize = 20;
|
||||
string name = "";
|
||||
void Start()
|
||||
{
|
||||
ApiBase.SetCookie("73385F5F719B610D132C1ECF3E9143272BF15214D57ED91CD7A9DFD832407471535112AAEB8E9271F75D54FBBF2D99F18FA313C1EEA5676F5D722D7FBB07C926BEC5905591BF9AFDDC6336552DF273112C2DA1794E6FA2F465B11FECD2E82E52");
|
||||
InitialColor();
|
||||
scroll = transform.Find("ListPanel").Find("Scroll").GetComponent<ScrollRect>();
|
||||
btnMatch = transform.Find("ListPanel").Find("BtnMatch");
|
||||
btnRoute = transform.Find("ListPanel").Find("BtnRoute");
|
||||
searchInput = transform.Find("ListPanel").Find("SearchInput");
|
||||
scrollContent = scroll.transform.Find("Viewport").Find("Content");
|
||||
routeScroll = scrollContent.Find("RouteList");
|
||||
routeContent = routeScroll.Find("Viewport").Find("Content");
|
||||
matchScroll = scrollContent.Find("MatchList");
|
||||
matchContent = matchScroll.Find("Viewport").Find("Content");
|
||||
if (btnMatch != null)
|
||||
{
|
||||
btnMatch.GetComponent<Button>().onClick.AddListener(() => StartScroll(0));
|
||||
}
|
||||
if (btnRoute != null)
|
||||
{
|
||||
btnRoute.GetComponent<Button>().onClick.AddListener(() => StartScroll(1));
|
||||
}
|
||||
if (searchInput != null)
|
||||
{
|
||||
searchInput.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
name = searchInput.GetComponent<InputField>().text;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
if (routeScroll != null)
|
||||
{
|
||||
UIManager.AddEvent(routeScroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
if (matchScroll)
|
||||
{
|
||||
UIManager.AddEvent(matchScroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
GetList();
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData e)
|
||||
{
|
||||
var pe = (PointerEventData)e;
|
||||
var scrollrect = pe.pointerDrag.GetComponent<ScrollRect>();
|
||||
if (scrollrect.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= 1)
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
routeContent.transform.DestroyChildren();
|
||||
pageIndex = 0;
|
||||
GetList();
|
||||
}
|
||||
bool isEnd = false;
|
||||
void GetList()
|
||||
{
|
||||
var r =ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex, 20);
|
||||
if (r.result)
|
||||
{
|
||||
if (r.data.Count == 0 && pageIndex != 0)
|
||||
{
|
||||
isEnd = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = false;
|
||||
DisplayRouteResult(r.data,routeContent);
|
||||
DisplayRouteResult(r.data, matchContent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
}
|
||||
void DisplayRouteResult(List<RouteResult> list,Transform content)
|
||||
{
|
||||
if (routeResult != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(routeResult);
|
||||
obj.GetComponent<RouteItem>().Initial(item);
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.parent = content;
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
void InitialColor()
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#FFFFFF", out c1);
|
||||
ColorUtility.TryParseHtmlString("#5C5C6E", out c2);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
GoScroll();
|
||||
}
|
||||
void StartScroll(int index)
|
||||
{
|
||||
if (startScroll) return;
|
||||
if (index == 0)
|
||||
{
|
||||
//翻到比赛页,比赛按钮变白,线路按钮变灰
|
||||
scrollIndex = 1;
|
||||
startScroll = true;
|
||||
btnRoute.GetComponent<Text>().color = c2;
|
||||
btnMatch.GetComponent<Text>().color = c1;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
//反过来
|
||||
scrollIndex = 0;
|
||||
startScroll = true;
|
||||
btnRoute.GetComponent<Text>().color = c1;
|
||||
btnMatch.GetComponent<Text>().color = c2;
|
||||
}
|
||||
}
|
||||
#region 主页面滑动逻辑
|
||||
int scrollIndex = 0;
|
||||
bool startScroll = false;
|
||||
ScrollRect scroll;
|
||||
//private float scrollValue = 0.5f;
|
||||
int pageNums = 2;
|
||||
void GoScroll()
|
||||
{
|
||||
var index = scrollIndex;
|
||||
var scrollValue = 1f / (pageNums - 1);
|
||||
var value = index * scrollValue;
|
||||
if (scroll != null && startScroll)
|
||||
{
|
||||
if (scroll.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
scroll.horizontalNormalizedPosition -= (scrollValue / 20);
|
||||
if (scroll.horizontalNormalizedPosition <= value)
|
||||
{
|
||||
Debug.Log(index);
|
||||
scroll.horizontalNormalizedPosition = value;
|
||||
startScroll = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scroll.horizontalNormalizedPosition += (scrollValue / 20);
|
||||
if (scroll.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
Debug.Log(index);
|
||||
scroll.horizontalNormalizedPosition = value;
|
||||
startScroll = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
//float scrollIndex = 0;
|
||||
//bool startScroll = false;
|
||||
//ScrollRect scroll;
|
||||
//void GoScroll()
|
||||
//{
|
||||
// float value = scrollIndex;
|
||||
// if (scroll != null && startScroll)
|
||||
// {
|
||||
// if (scrollIndex == 0)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition -= (1f / 20);
|
||||
// if (scroll.horizontalNormalizedPosition <= 0)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition = 0;
|
||||
// startScroll = false;
|
||||
|
||||
// }
|
||||
// }
|
||||
// else if (scrollIndex == 1)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition += (1f / 20);
|
||||
// if (scroll.horizontalNormalizedPosition >= 1)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition = 1;
|
||||
// startScroll = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9e4a559c32ef6d4a95d06e4a10c73d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
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 RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Transform left,row1,row2,right;
|
||||
Transform btnReRide, btnContinue, btnDelete;
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
string titleColor = "#5c5c6e";
|
||||
public void Initial(RouteResult result)
|
||||
{
|
||||
left = transform.Find("Left");
|
||||
row1 = left.Find("Main").Find("Row1");
|
||||
row2 = left.Find("Main").Find("Row2");
|
||||
Utils.DisplayImage(StartCoroutine, transform.Find("CoverImage").GetComponent<RawImage>(), result.RouteImage);
|
||||
left.Find("Main").Find("Name").GetComponent<Text>().text = result.RouteName;
|
||||
left.Find("Main").Find("Time").GetComponent<Text>().text = result.CreateTime.ToString("yyyy-MM-dd HH-mm-ss");
|
||||
row1.Find("Time").GetComponent<Text>().text = $"<color={titleColor}>Riding time:</color>{result.TrainingTime}";
|
||||
row1.Find("Distance").GetComponent<Text>().text = $"<color={titleColor}>Mileage:</color>{result.EndDistance.ToString("#0.00")}KM";
|
||||
row1.Find("Times").GetComponent<Text>().text = $"<color={titleColor}>Times:</color>{result.Count}";
|
||||
row1.Find("Rank").GetComponent<Text>().text = $"<color={titleColor}>Rank:</color>{result.Ranking}";
|
||||
left.Find("Progress").Find("Image").GetComponent<Image>().fillAmount = (float)result.Progress;
|
||||
left.Find("Progress").Find("Value").GetComponent<Text>().text = (result.Progress * 100).ToString("#0");
|
||||
row2.Find("Device").GetComponent<Text>().text = $"<color={titleColor}>Cycling equipment:</color>{result.ManufacturerName}";
|
||||
right = transform.Find("Right");
|
||||
btnContinue = right.Find("BtnContinue");
|
||||
if (btnContinue)
|
||||
{
|
||||
btnContinue.gameObject.SetActive(false);
|
||||
btnContinue.GetComponent<Button>().onClick.AddListener(GoContinue);
|
||||
}
|
||||
btnReRide = right.Find("BtnReRide");
|
||||
if (btnReRide)
|
||||
{
|
||||
btnReRide.gameObject.SetActive(false);
|
||||
btnReRide.GetComponent<Button>().onClick.AddListener(GoReRide);
|
||||
}
|
||||
btnDelete = right.Find("BtnDelete");
|
||||
if (btnDelete)
|
||||
{
|
||||
btnDelete.gameObject.SetActive(false);
|
||||
btnDelete.GetComponent<Button>().onClick.AddListener(Delete);
|
||||
}
|
||||
}
|
||||
|
||||
private void Delete()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void GoReRide()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void GoContinue()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
transform.GetComponent<Image>().color = Utils.HexToColorHtml("#23232d");
|
||||
if (left != null)
|
||||
{
|
||||
left.Find("Main").Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#414251");
|
||||
left.Find("Progress").Find("Image").GetComponent<Image>().color = Utils.HexToColorHtml("#5c5c6e");
|
||||
left.Find("Progress").Find("Value").GetComponent<Text>().color = Utils.HexToColorHtml("#414251");
|
||||
left.Find("Progress").Find("bf").GetComponent<Text>().color = Utils.HexToColorHtml("#414251");
|
||||
}
|
||||
if (row1 != null)
|
||||
{
|
||||
row1.Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
row1.Find("Distance").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
row1.Find("Times").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
row1.Find("Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#9E9EAD");
|
||||
}
|
||||
titleColor = "#414251";
|
||||
btnContinue.gameObject.SetActive(false);
|
||||
btnReRide.gameObject.SetActive(false);
|
||||
btnDelete.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
transform.GetComponent<Image>().color = Utils.HexToColorHtml("#353543");
|
||||
if (left != null)
|
||||
{
|
||||
left.Find("Main").Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#5c5c6e");
|
||||
left.Find("Progress").Find("Image").GetComponent<Image>().color = Utils.HexToColorHtml("#F93086");
|
||||
left.Find("Progress").Find("Value").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
left.Find("Progress").Find("bf").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
if (row1 != null)
|
||||
{
|
||||
row1.Find("Time").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
row1.Find("Distance").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
row1.Find("Times").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
row1.Find("Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
titleColor = "#5c5c6e";
|
||||
btnContinue.gameObject.SetActive(true);
|
||||
btnReRide.gameObject.SetActive(true);
|
||||
btnDelete.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f822eddd7a641a744a198d79e43e3f55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 332b0c4457df8c643a527441f5be862e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3d31d70cf492e34096ffdc82042d396
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,565 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
#if TMP_PRESENT
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for effects that modify the generated Mesh.
|
||||
/// It works well not only for standard Graphic components (Image, RawImage, Text, etc.) but also for TextMeshPro and TextMeshProUGUI.
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public abstract class BaseMeshEffect : UIBehaviour, IMeshModifier
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
#if TMP_PRESENT
|
||||
static readonly List<Vector2> s_Uv0 = new List<Vector2> (4096);
|
||||
static readonly List<Vector2> s_Uv1 = new List<Vector2> (4096);
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
static readonly List<Vector2> s_Uv2 = new List<Vector2> (4096);
|
||||
static readonly List<Vector2> s_Uv3 = new List<Vector2> (4096);
|
||||
#endif
|
||||
static readonly List<Vector3> s_Vertices = new List<Vector3> (4096);
|
||||
static readonly List<int> s_Indices = new List<int> (4096);
|
||||
static readonly List<Vector3> s_Normals = new List<Vector3> (4096);
|
||||
static readonly List<Vector4> s_Tangents = new List<Vector4> (4096);
|
||||
static readonly List<Color32> s_Colors = new List<Color32> (4096);
|
||||
static readonly VertexHelper s_VertexHelper = new VertexHelper ();
|
||||
static readonly List<TMP_SubMeshUI> s_SubMeshUIs = new List<TMP_SubMeshUI> (4096);
|
||||
static readonly List<Mesh> s_Meshes = new List<Mesh> (4096);
|
||||
static readonly List<UIVertex> s_UIVertices = new List<UIVertex> (4096);
|
||||
static readonly List<BaseMeshEffect> s_TmpEffects = new List<BaseMeshEffect>(4);
|
||||
#endif
|
||||
static readonly Material[] s_EmptyMaterials = new Material[0];
|
||||
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// The Graphic attached to this GameObject.
|
||||
/// </summary>
|
||||
public Graphic graphic { get { Initialize(); return _graphic; } }
|
||||
|
||||
/// <summary>
|
||||
/// The CanvasRenderer attached to this GameObject.
|
||||
/// </summary>
|
||||
public CanvasRenderer canvasRenderer { get { Initialize(); return _canvasRenderer; } }
|
||||
|
||||
#if TMP_PRESENT
|
||||
/// <summary>
|
||||
/// The TMP_Text attached to this GameObject.
|
||||
/// </summary>
|
||||
public TMP_Text textMeshPro { get { Initialize (); return _textMeshPro; } }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// The RectTransform attached to this GameObject.
|
||||
/// </summary>
|
||||
public RectTransform rectTransform { get { Initialize(); return _rectTransform; } }
|
||||
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
/// <summary>
|
||||
/// Additional canvas shader channels to use this component.
|
||||
/// </summary>
|
||||
public virtual AdditionalCanvasShaderChannels requiredChannels { get { return AdditionalCanvasShaderChannels.None; } }
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Is TextMeshPro or TextMeshProUGUI attached to this GameObject?
|
||||
/// </summary>
|
||||
public bool isTMPro
|
||||
{
|
||||
get
|
||||
{
|
||||
#if TMP_PRESENT
|
||||
return textMeshPro != null;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The material for rendering.
|
||||
/// </summary>
|
||||
public virtual Material material
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
#if TMP_PRESENT
|
||||
if (textMeshPro)
|
||||
{
|
||||
return textMeshPro.fontSharedMaterial;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (graphic)
|
||||
{
|
||||
return graphic.material;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
#if TMP_PRESENT
|
||||
if (textMeshPro)
|
||||
{
|
||||
textMeshPro.fontSharedMaterial = value;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (graphic)
|
||||
{
|
||||
graphic.material = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Material[] materials
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
#if TMP_PRESENT
|
||||
if (textMeshPro)
|
||||
{
|
||||
return textMeshPro.fontSharedMaterials ?? s_EmptyMaterials;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (graphic)
|
||||
{
|
||||
_materials[0] = graphic.material;
|
||||
return _materials;
|
||||
}
|
||||
else
|
||||
{
|
||||
return s_EmptyMaterials;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call used to modify mesh. (legacy)
|
||||
/// </summary>
|
||||
/// <param name="mesh">Mesh.</param>
|
||||
public virtual void ModifyMesh(Mesh mesh)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Call used to modify mesh.
|
||||
/// </summary>
|
||||
/// <param name="vh">VertexHelper.</param>
|
||||
public virtual void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mark the vertices as dirty.
|
||||
/// </summary>
|
||||
public virtual void SetVerticesDirty()
|
||||
{
|
||||
#if TMP_PRESENT
|
||||
if (textMeshPro)
|
||||
{
|
||||
foreach (var info in textMeshPro.textInfo.meshInfo)
|
||||
{
|
||||
var mesh = info.mesh;
|
||||
if (mesh)
|
||||
{
|
||||
mesh.Clear ();
|
||||
mesh.vertices = info.vertices;
|
||||
mesh.uv = info.uvs0;
|
||||
mesh.uv2 = info.uvs2;
|
||||
mesh.colors32 = info.colors32;
|
||||
mesh.normals = info.normals;
|
||||
mesh.tangents = info.tangents;
|
||||
mesh.triangles = info.triangles;
|
||||
}
|
||||
}
|
||||
|
||||
if (canvasRenderer)
|
||||
{
|
||||
canvasRenderer.SetMesh (textMeshPro.mesh);
|
||||
|
||||
GetComponentsInChildren (false, s_SubMeshUIs);
|
||||
foreach (var sm in s_SubMeshUIs)
|
||||
{
|
||||
sm.canvasRenderer.SetMesh (sm.mesh);
|
||||
}
|
||||
s_SubMeshUIs.Clear ();
|
||||
}
|
||||
textMeshPro.havePropertiesChanged = true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (graphic)
|
||||
{
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowTMProWarning(Shader shader, Shader mobileShader, Shader spriteShader, System.Action<Material> onCreatedMaterial)
|
||||
{
|
||||
#if UNITY_EDITOR && TMP_PRESENT
|
||||
if(!textMeshPro || !textMeshPro.fontSharedMaterial)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Is the material preset for dissolve?
|
||||
Material m = textMeshPro.fontSharedMaterial;
|
||||
if (m.shader != shader && m.shader != mobileShader)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal ();
|
||||
EditorGUILayout.HelpBox (string.Format("{0} requires '{1}' or '{2}' as a shader for material preset.", GetType().Name, shader.name, mobileShader.name), MessageType.Warning);
|
||||
if(GUILayout.Button ("Fix"))
|
||||
{
|
||||
var correctShader = m.shader.name.Contains ("Mobile") ? mobileShader : shader;
|
||||
textMeshPro.fontSharedMaterial = ModifyTMProMaterialPreset (m, correctShader, onCreatedMaterial);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal ();
|
||||
return;
|
||||
}
|
||||
|
||||
// Is the sprite asset for dissolve?
|
||||
TMP_SpriteAsset spriteAsset = textMeshPro.spriteAsset ?? TMP_Settings.GetSpriteAsset ();
|
||||
// Sprite asset might not exist at all
|
||||
if(spriteAsset == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m = spriteAsset.material;
|
||||
if (m && m.shader != spriteShader && textMeshPro.richText && textMeshPro.text.Contains("<sprite="))
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal ();
|
||||
EditorGUILayout.HelpBox (string.Format ("{0} requires '{1}' as a shader for sprite asset.", GetType().Name,spriteShader.name), MessageType.Warning);
|
||||
if (GUILayout.Button ("Fix"))
|
||||
{
|
||||
GetComponentsInChildren<TMP_SubMesh> ().Select (x => x.gameObject).ToList ().ForEach (DestroyImmediate);
|
||||
GetComponentsInChildren<TMP_SubMeshUI> ().Select (x => x.gameObject).ToList ().ForEach (DestroyImmediate);
|
||||
textMeshPro.spriteAsset = ModifyTMProSpriteAsset (m, spriteShader, onCreatedMaterial);
|
||||
}
|
||||
EditorGUILayout.EndHorizontal ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Material ModifyTMProMaterialPreset (Material baseMaterial, Shader shader, System.Action<Material> onCreatedMaterial)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath (baseMaterial);
|
||||
string filename = Path.GetFileNameWithoutExtension (path) + " (" + GetType ().Name + ")";
|
||||
Material mat = Resources.Load<Material> (TMP_Settings.defaultFontAssetPath + filename);
|
||||
if (!mat)
|
||||
{
|
||||
mat = new Material (baseMaterial)
|
||||
{
|
||||
shaderKeywords = baseMaterial.shaderKeywords,
|
||||
shader = shader,
|
||||
};
|
||||
onCreatedMaterial (mat);
|
||||
AssetDatabase.CreateAsset (mat, Path.GetDirectoryName (path) + "/" + filename + ".mat");
|
||||
|
||||
EditorUtility.FocusProjectWindow ();
|
||||
EditorGUIUtility.PingObject (mat);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.shader = shader;
|
||||
}
|
||||
EditorUtility.SetDirty (mat);
|
||||
return mat;
|
||||
}
|
||||
|
||||
TMP_SpriteAsset ModifyTMProSpriteAsset (Material baseMaterial, Shader shader, System.Action<Material> onCreatedMaterial)
|
||||
{
|
||||
string path = AssetDatabase.GetAssetPath (baseMaterial);
|
||||
string filename = Path.GetFileNameWithoutExtension (path) + " (" + this.GetType ().Name + ")";
|
||||
TMP_SpriteAsset spriteAsset = Resources.Load<TMP_SpriteAsset> (TMP_Settings.defaultSpriteAssetPath + filename);
|
||||
if (!spriteAsset)
|
||||
{
|
||||
AssetDatabase.CopyAsset (path, Path.GetDirectoryName (path) + "/" + filename + ".mat");
|
||||
spriteAsset = Resources.Load<TMP_SpriteAsset> (TMP_Settings.defaultSpriteAssetPath + filename);
|
||||
spriteAsset.material.shader = shader;
|
||||
spriteAsset.material.name = shader.name;
|
||||
onCreatedMaterial (spriteAsset.material);
|
||||
|
||||
EditorUtility.FocusProjectWindow ();
|
||||
EditorGUIUtility.PingObject (spriteAsset);
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteAsset.material.shader = shader;
|
||||
}
|
||||
EditorUtility.SetDirty (spriteAsset);
|
||||
return spriteAsset;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// Should the effect modify the mesh directly for TMPro?
|
||||
/// </summary>
|
||||
protected virtual bool isLegacyMeshModifier { get { return false; } }
|
||||
|
||||
|
||||
protected virtual void Initialize()
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
_initialized = true;
|
||||
_graphic = _graphic ?? GetComponent<Graphic>();
|
||||
_canvasRenderer = _canvasRenderer ?? GetComponent<CanvasRenderer>();
|
||||
_rectTransform = _rectTransform ?? GetComponent<RectTransform>();
|
||||
#if TMP_PRESENT
|
||||
_textMeshPro = _textMeshPro ?? GetComponent<TMP_Text> ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_initialized = false;
|
||||
SetVerticesDirty();
|
||||
#if TMP_PRESENT
|
||||
if (textMeshPro)
|
||||
{
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Add (OnTextChanged);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_EDITOR && TMP_PRESENT
|
||||
if (graphic && textMeshPro)
|
||||
{
|
||||
GraphicRebuildTracker.TrackGraphic (graphic);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
if (graphic)
|
||||
{
|
||||
AdditionalCanvasShaderChannels channels = requiredChannels;
|
||||
var canvas = graphic.canvas;
|
||||
if (canvas && (canvas.additionalShaderChannels & channels) != channels)
|
||||
{
|
||||
Debug.LogWarningFormat(this, "Enable {1} of Canvas.additionalShaderChannels to use {0}.", GetType().Name, channels);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the behaviour becomes disabled () or inactive.
|
||||
/// </summary>
|
||||
protected override void OnDisable()
|
||||
{
|
||||
#if TMP_PRESENT
|
||||
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove (OnTextChanged);
|
||||
#endif
|
||||
SetVerticesDirty();
|
||||
|
||||
#if UNITY_EDITOR && TMP_PRESENT
|
||||
if (graphic && textMeshPro)
|
||||
{
|
||||
GraphicRebuildTracker.UnTrackGraphic (graphic);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LateUpdate is called every frame, if the Behaviour is enabled.
|
||||
/// </summary>
|
||||
protected virtual void LateUpdate()
|
||||
{
|
||||
#if TMP_PRESENT
|
||||
if (textMeshPro)
|
||||
{
|
||||
if (textMeshPro.havePropertiesChanged || _isTextMeshProActive != textMeshPro.isActiveAndEnabled)
|
||||
{
|
||||
SetVerticesDirty ();
|
||||
}
|
||||
_isTextMeshProActive = textMeshPro.isActiveAndEnabled;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when properties have been changed by animation.
|
||||
/// </summary>
|
||||
protected override void OnDidApplyAnimationProperties()
|
||||
{
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// This function is called when the script is loaded or a value is changed in the inspector (Called in the editor only).
|
||||
/// </summary>
|
||||
protected override void OnValidate()
|
||||
{
|
||||
SetVerticesDirty();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
bool _initialized;
|
||||
CanvasRenderer _canvasRenderer;
|
||||
RectTransform _rectTransform;
|
||||
Graphic _graphic;
|
||||
Material[] _materials = new Material[1];
|
||||
|
||||
#if TMP_PRESENT
|
||||
bool _isTextMeshProActive;
|
||||
TMP_Text _textMeshPro;
|
||||
|
||||
/// <summary>
|
||||
/// Called when any TextMeshPro generated the mesh.
|
||||
/// </summary>
|
||||
/// <param name="obj">TextMeshPro object.</param>
|
||||
void OnTextChanged (Object obj)
|
||||
{
|
||||
// Skip if the object is different from the current object or the text is empty.
|
||||
var textInfo = textMeshPro.textInfo;
|
||||
if (textMeshPro != obj || textInfo.characterCount - textInfo.spaceCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GetComponents<BaseMeshEffect>(s_TmpEffects);
|
||||
for (int i = 0; i < s_TmpEffects.Count; i++)
|
||||
{
|
||||
if (s_TmpEffects[i].enabled)
|
||||
{
|
||||
if (s_TmpEffects[i] == this)
|
||||
break;
|
||||
else
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Collect the meshes.
|
||||
s_Meshes.Clear ();
|
||||
foreach (var info in textInfo.meshInfo)
|
||||
{
|
||||
s_Meshes.Add (info.mesh);
|
||||
}
|
||||
|
||||
// Modify the meshes.
|
||||
foreach (var e in s_TmpEffects)
|
||||
{
|
||||
if (!e.enabled)
|
||||
continue;
|
||||
|
||||
if (e.isLegacyMeshModifier)
|
||||
{
|
||||
// Legacy mode: Modify the meshes directly.
|
||||
foreach (var m in s_Meshes)
|
||||
{
|
||||
if (m)
|
||||
{
|
||||
e.ModifyMesh(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert meshes to VertexHelpers and modify them.
|
||||
foreach (var m in s_Meshes)
|
||||
{
|
||||
if (m)
|
||||
{
|
||||
FillVertexHelper(s_VertexHelper, m);
|
||||
e.ModifyMesh(s_VertexHelper);
|
||||
s_VertexHelper.FillMesh(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the modified meshes to the CanvasRenderers (for UI only).
|
||||
if (canvasRenderer)
|
||||
{
|
||||
canvasRenderer.SetMesh (textMeshPro.mesh);
|
||||
GetComponentsInChildren (false, s_SubMeshUIs);
|
||||
foreach (var sm in s_SubMeshUIs)
|
||||
{
|
||||
sm.canvasRenderer.SetMesh (sm.mesh);
|
||||
}
|
||||
s_SubMeshUIs.Clear ();
|
||||
}
|
||||
|
||||
// Clear.
|
||||
s_Meshes.Clear ();
|
||||
}
|
||||
|
||||
void FillVertexHelper (VertexHelper vh, Mesh mesh)
|
||||
{
|
||||
vh.Clear ();
|
||||
|
||||
mesh.GetVertices (s_Vertices);
|
||||
mesh.GetColors (s_Colors);
|
||||
mesh.GetUVs (0, s_Uv0);
|
||||
mesh.GetUVs (1, s_Uv1);
|
||||
mesh.GetNormals (s_Normals);
|
||||
mesh.GetTangents (s_Tangents);
|
||||
mesh.GetIndices (s_Indices, 0);
|
||||
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
mesh.GetUVs (2, s_Uv2);
|
||||
mesh.GetUVs (3, s_Uv3);
|
||||
bool useUv2 = 0 < s_Uv2.Count;
|
||||
bool useUv3 = 0 < s_Uv3.Count;
|
||||
#endif
|
||||
|
||||
s_UIVertices.Clear();
|
||||
UIVertex v = default(UIVertex);
|
||||
for (int i = 0; i < s_Vertices.Count; i++)
|
||||
{
|
||||
v.position = s_Vertices[i];
|
||||
v.color = s_Colors[i];
|
||||
v.uv0 = s_Uv0[i];
|
||||
v.uv1 = s_Uv1[i];
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
if (useUv2 && i < s_Uv2.Count)
|
||||
v.uv2 = s_Uv2[i];
|
||||
if (useUv3 && i < s_Uv3.Count)
|
||||
v.uv3 = s_Uv3[i];
|
||||
#endif
|
||||
v.normal = s_Normals[i];
|
||||
v.tangent = s_Tangents[i];
|
||||
|
||||
s_UIVertices.Add(v);
|
||||
}
|
||||
s_VertexHelper.AddUIVertexStream(s_UIVertices, s_Indices);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c52a957894a7bbf418d6b190bd7816a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,386 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// UIGradient.
|
||||
/// </summary>
|
||||
[DisallowMultipleComponent]
|
||||
[AddComponentMenu("UI/MeshEffectForTextMeshPro/UIGradient", 101)]
|
||||
public class UIGradient : Assets.Scripts.UI.UIEffect.Common.BaseMeshEffect
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
|
||||
/// <summary>
|
||||
/// Gradient direction.
|
||||
/// </summary>
|
||||
public enum Direction
|
||||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
Angle,
|
||||
Diagonal,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient space for Text.
|
||||
/// </summary>
|
||||
public enum GradientStyle
|
||||
{
|
||||
Rect,
|
||||
Fit,
|
||||
Split,
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Serialize Members.
|
||||
//################################
|
||||
|
||||
[Tooltip("Gradient Direction.")]
|
||||
[SerializeField] Direction m_Direction;
|
||||
|
||||
[Tooltip("Color1: Top or Left.")]
|
||||
[SerializeField] Color m_Color1 = Color.white;
|
||||
|
||||
[Tooltip("Color2: Bottom or Right.")]
|
||||
[SerializeField] Color m_Color2 = Color.white;
|
||||
|
||||
[Tooltip("Color3: For diagonal.")]
|
||||
[SerializeField] Color m_Color3 = Color.white;
|
||||
|
||||
[Tooltip("Color4: For diagonal.")]
|
||||
[SerializeField] Color m_Color4 = Color.white;
|
||||
|
||||
[Tooltip("Gradient rotation.")]
|
||||
[SerializeField] [Range(-180, 180)] float m_Rotation;
|
||||
|
||||
[Tooltip("Gradient offset for Horizontal, Vertical or Angle.")]
|
||||
[SerializeField] [Range(-1, 1)] float m_Offset1;
|
||||
|
||||
[Tooltip("Gradient offset for Diagonal.")]
|
||||
[SerializeField] [Range(-1, 1)] float m_Offset2;
|
||||
|
||||
[Tooltip("Gradient style for Text.")]
|
||||
[SerializeField] GradientStyle m_GradientStyle;
|
||||
|
||||
[Tooltip("Color space to correct color.")]
|
||||
[SerializeField] ColorSpace m_ColorSpace = ColorSpace.Uninitialized;
|
||||
|
||||
[Tooltip("Ignore aspect ratio.")]
|
||||
[SerializeField] bool m_IgnoreAspectRatio = true;
|
||||
|
||||
|
||||
//################################
|
||||
// Public Members.
|
||||
//################################
|
||||
public Graphic targetGraphic { get { return base.graphic; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gradient Direction.
|
||||
/// </summary>
|
||||
public Direction direction
|
||||
{
|
||||
get { return m_Direction; }
|
||||
set
|
||||
{
|
||||
if (m_Direction != value)
|
||||
{
|
||||
m_Direction = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color1: Top or Left.
|
||||
/// </summary>
|
||||
public Color color1
|
||||
{
|
||||
get { return m_Color1; }
|
||||
set
|
||||
{
|
||||
if (m_Color1 != value)
|
||||
{
|
||||
m_Color1 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color2: Bottom or Right.
|
||||
/// </summary>
|
||||
public Color color2
|
||||
{
|
||||
get { return m_Color2; }
|
||||
set
|
||||
{
|
||||
if (m_Color2 != value)
|
||||
{
|
||||
m_Color2 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color3: For diagonal.
|
||||
/// </summary>
|
||||
public Color color3
|
||||
{
|
||||
get { return m_Color3; }
|
||||
set
|
||||
{
|
||||
if (m_Color3 != value)
|
||||
{
|
||||
m_Color3 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color4: For diagonal.
|
||||
/// </summary>
|
||||
public Color color4
|
||||
{
|
||||
get { return m_Color4; }
|
||||
set
|
||||
{
|
||||
if (m_Color4 != value)
|
||||
{
|
||||
m_Color4 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient rotation.
|
||||
/// </summary>
|
||||
public float rotation
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Direction == Direction.Horizontal ? -90
|
||||
: m_Direction == Direction.Vertical ? 0
|
||||
: m_Rotation;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Mathf.Approximately(m_Rotation, value))
|
||||
{
|
||||
m_Rotation = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient offset for Horizontal, Vertical or Angle.
|
||||
/// </summary>
|
||||
public float offset
|
||||
{
|
||||
get { return m_Offset1; }
|
||||
set
|
||||
{
|
||||
if (m_Offset1 != value)
|
||||
{
|
||||
m_Offset1 = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient offset for Diagonal.
|
||||
/// </summary>
|
||||
public Vector2 offset2
|
||||
{
|
||||
get { return new Vector2(m_Offset2, m_Offset1); }
|
||||
set
|
||||
{
|
||||
if (m_Offset1 != value.y || m_Offset2 != value.x)
|
||||
{
|
||||
m_Offset1 = value.y;
|
||||
m_Offset2 = value.x;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gradient style for Text.
|
||||
/// </summary>
|
||||
public GradientStyle gradientStyle
|
||||
{
|
||||
get { return m_GradientStyle; }
|
||||
set
|
||||
{
|
||||
if (m_GradientStyle != value)
|
||||
{
|
||||
m_GradientStyle = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Color space to correct color.
|
||||
/// </summary>
|
||||
public ColorSpace colorSpace
|
||||
{
|
||||
get { return m_ColorSpace; }
|
||||
set
|
||||
{
|
||||
if (m_ColorSpace != value)
|
||||
{
|
||||
m_ColorSpace = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ignore aspect ratio.
|
||||
/// </summary>
|
||||
public bool ignoreAspectRatio
|
||||
{
|
||||
get { return m_IgnoreAspectRatio; }
|
||||
set
|
||||
{
|
||||
if (m_IgnoreAspectRatio != value)
|
||||
{
|
||||
m_IgnoreAspectRatio = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Call used to modify mesh.
|
||||
/// </summary>
|
||||
public override void ModifyMesh(VertexHelper vh)
|
||||
{
|
||||
if (!IsActive())
|
||||
return;
|
||||
|
||||
// Gradient space.
|
||||
Rect rect = default(Rect);
|
||||
UIVertex vertex = default(UIVertex);
|
||||
if (m_GradientStyle == GradientStyle.Rect)
|
||||
{
|
||||
// RectTransform.
|
||||
rect = graphic.rectTransform.rect;
|
||||
}
|
||||
else if (m_GradientStyle == GradientStyle.Split)
|
||||
{
|
||||
// Each characters.
|
||||
rect.Set(0, 0, 1, 1);
|
||||
}
|
||||
else if (m_GradientStyle == GradientStyle.Fit)
|
||||
{
|
||||
// Fit to contents.
|
||||
rect.xMin = rect.yMin = float.MaxValue;
|
||||
rect.xMax = rect.yMax = float.MinValue;
|
||||
for (int i = 0; i < vh.currentVertCount; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vertex, i);
|
||||
rect.xMin = Mathf.Min(rect.xMin, vertex.position.x);
|
||||
rect.yMin = Mathf.Min(rect.yMin, vertex.position.y);
|
||||
rect.xMax = Mathf.Max(rect.xMax, vertex.position.x);
|
||||
rect.yMax = Mathf.Max(rect.yMax, vertex.position.y);
|
||||
}
|
||||
}
|
||||
|
||||
// Gradient rotation.
|
||||
float rad = rotation * Mathf.Deg2Rad;
|
||||
Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad));
|
||||
if (!m_IgnoreAspectRatio && Direction.Angle <= m_Direction)
|
||||
{
|
||||
dir.x *= rect.height / rect.width;
|
||||
dir = dir.normalized;
|
||||
}
|
||||
|
||||
// Calculate vertex color.
|
||||
Color color;
|
||||
Vector2 nomalizedPos;
|
||||
Matrix2x3 localMatrix = new Matrix2x3(rect, dir.x, dir.y); // Get local matrix.
|
||||
for (int i = 0; i < vh.currentVertCount; i++)
|
||||
{
|
||||
vh.PopulateUIVertex(ref vertex, i);
|
||||
|
||||
// Normalize vertex position by local matrix.
|
||||
if (m_GradientStyle == GradientStyle.Split)
|
||||
{
|
||||
// Each characters.
|
||||
nomalizedPos = localMatrix * s_SplitedCharacterPosition[i % 4] + offset2;
|
||||
}
|
||||
else
|
||||
{
|
||||
nomalizedPos = localMatrix * vertex.position + offset2;
|
||||
}
|
||||
|
||||
// Interpolate vertex color.
|
||||
if (direction == Direction.Diagonal)
|
||||
{
|
||||
color = Color.LerpUnclamped(
|
||||
Color.LerpUnclamped(m_Color1, m_Color2, nomalizedPos.x),
|
||||
Color.LerpUnclamped(m_Color3, m_Color4, nomalizedPos.x),
|
||||
nomalizedPos.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color.LerpUnclamped(m_Color2, m_Color1, nomalizedPos.y);
|
||||
}
|
||||
|
||||
// Correct color.
|
||||
vertex.color *= (m_ColorSpace == ColorSpace.Gamma) ? color.gamma
|
||||
: (m_ColorSpace == ColorSpace.Linear) ? color.linear
|
||||
: color;
|
||||
|
||||
vh.SetUIVertex(vertex, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
static readonly Vector2[] s_SplitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
|
||||
|
||||
/// <summary>
|
||||
/// Matrix2x3.
|
||||
/// </summary>
|
||||
struct Matrix2x3
|
||||
{
|
||||
public float m00, m01, m02, m10, m11, m12;
|
||||
|
||||
public Matrix2x3(Rect rect, float cos, float sin)
|
||||
{
|
||||
const float center = 0.5f;
|
||||
float dx = -rect.xMin / rect.width - center;
|
||||
float dy = -rect.yMin / rect.height - center;
|
||||
m00 = cos / rect.width;
|
||||
m01 = -sin / rect.height;
|
||||
m02 = dx * cos - dy * sin + center;
|
||||
m10 = sin / rect.width;
|
||||
m11 = cos / rect.height;
|
||||
m12 = dx * sin + dy * cos + center;
|
||||
}
|
||||
|
||||
public static Vector2 operator *(Matrix2x3 m, Vector2 v)
|
||||
{
|
||||
return new Vector2(
|
||||
(m.m00 * v.x) + (m.m01 * v.y) + m.m02,
|
||||
(m.m10 * v.x) + (m.m11 * v.y) + m.m12
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7245fe6cb36dc7b4e921e9ae44200f43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+40
-12
@@ -20,6 +20,8 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public GameObject Root;
|
||||
|
||||
private HomeController mHomePanel;
|
||||
public HomeController HomePanel
|
||||
{
|
||||
@@ -46,7 +48,7 @@ public class UIManager : MonoBehaviour
|
||||
return this.GetPanelInstance("DevicePanel", ref this.mDeviceController);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private MapListController mMapListController;
|
||||
public MapListController MapListPanel
|
||||
{
|
||||
@@ -107,13 +109,13 @@ public class UIManager : MonoBehaviour
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private T GetPanelInstance<T>(string prefabName, ref T internalComponent)
|
||||
@@ -166,12 +168,27 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
if(prePanel != null)
|
||||
var root = UIManager.Instance.Root;
|
||||
for (int i = 0; i < root.transform.childCount; i++)
|
||||
{
|
||||
var panel1 = root.transform.GetChild(i).GetComponent<PFUIPanel>();
|
||||
if (panel1 != null)
|
||||
{
|
||||
panel1.Close();
|
||||
}
|
||||
}
|
||||
|
||||
if (prePanel != null)
|
||||
{
|
||||
prePanel.Close();
|
||||
}
|
||||
prePanel = panelToShow;
|
||||
}
|
||||
if (parent != null && parent.IsActive() == false)
|
||||
{
|
||||
parent.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
//foreach (Transform child in parent.transform)
|
||||
//{
|
||||
// //GameObject.Destroy(child);
|
||||
@@ -195,7 +212,7 @@ public class UIManager : MonoBehaviour
|
||||
panelToShow.transform.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
|
||||
panelToShow.transform.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0);
|
||||
}
|
||||
panelToShow.transform.localScale = parent.transform.localScale;
|
||||
panelToShow.transform.localScale = parent.transform.localScale;
|
||||
}
|
||||
|
||||
public static void ShowCustom(PFUIPanel panelToShow, GameObject parent = null, bool modal = false)
|
||||
@@ -261,7 +278,7 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
public static void ShowDevicePanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, UIManager.Instance.MainPanel);
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, null, true);
|
||||
}
|
||||
|
||||
public static void ShowEditUserPanel()
|
||||
@@ -272,7 +289,7 @@ public class UIManager : MonoBehaviour
|
||||
public static void ShowLoadingDialogBox()
|
||||
{
|
||||
}
|
||||
public static void ShowMapListPanel()
|
||||
public static void ShowMapListPanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.MapListPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
@@ -283,6 +300,16 @@ public class UIManager : MonoBehaviour
|
||||
UIManager.Show(UIManager.Instance.MapDetailPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
public static void ShowBigMapPanel()
|
||||
{
|
||||
UIManager.Instance.MainPanel.gameObject.SetActive(false);
|
||||
var obj = Resources.Load("UI/Prefab/Panel/BigMapPanel");
|
||||
//var root = UIManager.Instance.MainPanel.transform.parent.parent;
|
||||
var bigMap = (GameObject)Instantiate(obj, UIManager.Instance.Root.transform);
|
||||
|
||||
//prePanel = bigMap.GetComponent<PFUIPanel>();
|
||||
}
|
||||
|
||||
public static void AddEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction<BaseEventData> call)
|
||||
{
|
||||
EventTrigger et = gameObject.GetComponent<EventTrigger>();
|
||||
@@ -310,18 +337,18 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
//UIManager.Instance.ModalsPanel.transform.DetachChildren();
|
||||
//UIManager.Instance.ModalsPanel.transform.childCount
|
||||
for (int i = 0; i < 1; i++)
|
||||
//for (int i = 0; i < UIManager.Instance.ModalsPanel.transform.childCount; i++)
|
||||
{
|
||||
var obj = UIManager.Instance.ModalsPanel.transform.GetChild(i);
|
||||
var obj = UIManager.Instance.ModalsPanel.transform.GetChild(UIManager.Instance.ModalsPanel.transform.childCount - 1);
|
||||
obj.gameObject.SetActive(false);
|
||||
DestroyImmediate(obj.gameObject);
|
||||
//DestroyImmediate(obj.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public Alert alert = null;
|
||||
public static void ShowAlert(string msg)
|
||||
{
|
||||
if(UIManager.Instance == null)
|
||||
if (UIManager.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -332,7 +359,8 @@ public class UIManager : MonoBehaviour
|
||||
UIManager.Instance.alert.SetText(msg);
|
||||
UIManager.Show(UIManager.Instance.alert, null, true);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
UIManager.Instance.alert.Show();
|
||||
UIManager.Instance.alert.SetText(msg);
|
||||
}
|
||||
|
||||
@@ -91,5 +91,24 @@ namespace Assets.Scripts
|
||||
byte b = byte.Parse(hex.Substring(4, 2), NumberStyles.HexNumber);
|
||||
return new Color32(r, g, b, byte.MaxValue);
|
||||
}
|
||||
public static Color HexToColorHtml(string hex)
|
||||
{
|
||||
ColorUtility.TryParseHtmlString(hex, out Color c);
|
||||
return c;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate random digit code
|
||||
/// </summary>
|
||||
/// <param name="length">Length</param>
|
||||
/// <returns>Result string</returns>
|
||||
public static string GenerateRandomDigitCode(int length)
|
||||
{
|
||||
var random = new System.Random();
|
||||
string str = string.Empty;
|
||||
for (int i = 0; i < length; i++)
|
||||
str = String.Concat(str, random.Next(10).ToString());
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user