Merge remote-tracking branch 'origin/dev' into dev_lishuo

# Conflicts:
#	Assets/Scripts/App.cs
This commit is contained in:
lishuo committed 2021-04-28 15:49:24 +08:00
commit 614d067d25
39 files changed
+5682 -12276

No files matched your search

+6 -1
View File
@@ -119,7 +119,12 @@ namespace Assets.Scripts.Apis
{
return await PostAsync<JsonResult<object>>("/MemberFavoriteMap/Cancel", new { routeId });
}
public async Task<JsonResult<object>> DeleteRecord(string id)
{
return await PostAsync<JsonResult<object>>("/MapRecord/Delete", new { id });
}
public JsonResult<MapRouteRankingList> GetRouteRanking(int id,string type, int pageIndex,int pageSize,string name)
{
var url = $"Map/v1/GetRouteRanking?pageIndex={ 0 }&pageSize={ pageSize }&name={ name }&id={ id }&type={ type }&filterSelf={ true }";
+8 -5
View File
@@ -1,20 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using UnityEngine.Networking;
namespace Assets.Scripts.Apis
{
public class MapBoxApi: ApiBase
{
public string GetAddressInfo(string address)
public async Task<string> GetAddressInfo(string address)
{
var url = $"https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/{ address }.json?access_token={ App.MapBoxAccessToken }";
var res = Get(url);
var url = $"https://a.tiles.mapbox.com/geocoding/v5/mapbox.places/{ UnityWebRequest.EscapeURL(address) }.json?access_token={ App.MapBoxAccessToken }";
//var res = Get(url);
//return System.Text.Encoding.UTF8.GetString(res);
return res;
var result = await new HttpClient().GetAsync(url);
return await result.Content.ReadAsStringAsync();
//UnityWebRequest.
}
}
@@ -163,5 +163,7 @@ namespace Assets.Scripts.Apis.Models
///
/// </summary>
public string CanShareOnStrava { get; set; }
public string ViewUrl { get; set; }
}
}
+5 -1
View File
@@ -70,6 +70,7 @@ namespace Assets.Scripts.Apis
user.LastUpdateFtpTime = ret.data.LastUpdateFtpTime;
user.LastUpdateWeightTime = ret.data.LastUpdateWeightTime;
user.LastUpdateBicycleWeightTime = ret.data.LastUpdateBicycleWeightTime;
user.Height = ret.data.Height;
//todo: check local database, insert new user
//PubCommData.CurrentUser = user;
@@ -178,7 +179,10 @@ namespace Assets.Scripts.Apis
public async Task<JsonResult<UserResultModel>> QuickLogin()
{
var r = await PostAsync<JsonResult<UserResultModel>>("NoAuth/QuickLogin", null);
r.data.cookie = cookies[0].Value;
if (r.result)
{
r.data.cookie = cookies[0].Value;
}
return r;
}
+2
View File
@@ -33,5 +33,7 @@ public static class App
public static Texture CurrentUserHeadTexture;
public static RouteResult routeResult;//骑行记录向骑行场景传值
public static Texture DefaultRotateTexture;
//全局用 输入框或者下拉框修改标志位
public static bool isChanged { get; set; }
public static RideSetting rideSetting = new RideSetting();
}
+9 -5
View File
@@ -293,7 +293,10 @@ public class LoginController : MonoBehaviour
{
UIManager.AddEvent(exit.gameObject, EventTriggerType.PointerClick, (b) =>
{
Application.Quit();
UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", () =>
{
Application.Quit();
});
});
}
@@ -644,7 +647,7 @@ public class LoginController : MonoBehaviour
var CPassword = signForm.cpassword;
if (Password.text != CPassword.text)
{
Utils.showToast(gameObject, "两次密码输入不一致");
Utils.showToast(gameObject, "Two password entries are inconsistent");//两次密码输入不一致
return;
}
//JsonConvert
@@ -713,13 +716,13 @@ public class LoginController : MonoBehaviour
var CPassword = signForm.cpassword;
if (Password.text != CPassword.text)
{
Utils.showToast(gameObject, "两次密码输入不一致");
Utils.showToast(gameObject, "Two password entries are inconsistent");//两次密码输入不一致
return;
}
var r = await ConfigHelper.userApi.ResetPassword(Email.text, Captcha.text, Password.text);
if (r.result)
{
Utils.showToast(gameObject, "修改成功",type:1);
Utils.showToast(gameObject, "Success",type:1);
goLoginReturn2();
}
else
@@ -804,7 +807,7 @@ public class LoginController : MonoBehaviour
new { Field = "Months", ErrMsg = "" },
new { Field = "Days", ErrMsg = "" }
}));
Utils.showToast(gameObject, "请选择生日");
Utils.showToast(gameObject, "Please select birthday");//请选择生日
return false;
}
userResult.Sex = _genders.SelectedIndex + 1;
@@ -998,6 +1001,7 @@ public class LoginController : MonoBehaviour
UIManager.Instance.userInfoIndex = 0;
}
App.CurrentUser = data;
App.rideSetting.sensitivity = data.Sensitivity;
SceneManager.LoadScene("MainScene");
}
/// <summary>
+6 -2
View File
@@ -62,9 +62,12 @@ namespace Assets.Scripts.UI.Control
void Awake()
{
//this.mSelectedIndex =
//UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Select, new UnityEngine.Events.UnityAction<BaseEventData>(OnSelect));
UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Select, (b)=>
{
App.isChanged = true;
});
//UIManager.AddEvent(this.transform.GetComponent<Image>().gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(OnDeselect));
//this.GetComponent<Dropdown>().itemText.color = Utils.HexToColorHtml("#ff2742");
this.GetComponent<Dropdown>().onValueChanged.AddListener(i => {
mSelectedIndex = i;
@@ -99,6 +102,7 @@ namespace Assets.Scripts.UI.Control
var image = this.transform.GetComponent<Image>();
var png = Resources.Load<Sprite>("Images/ipt-1");
image.sprite = png;
App.isChanged = true;
}
public void OnDeselect(BaseEventData eventData)
{
+2 -1
View File
@@ -53,7 +53,8 @@ namespace Assets.Scripts.UI.Control
outline.enabled = true;
ColorUtility.TryParseHtmlString("#F93086", out Color color);
outline.effectColor = color;
outline.effectColor = color;
App.isChanged = true;
}
public void OnDeselect(BaseEventData eventData)
@@ -3,12 +3,12 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class LoadingPf : MonoBehaviour
public class LoadingPf : PFUIPanel
{
List<Sprite> sprites;
Image image;
private void Start()
protected override void Start()
{
sprites = new List<Sprite>();
for (int i = 1; i < 80; i++)
@@ -19,11 +19,14 @@ public class LoadingPf : MonoBehaviour
}
int index = 0;
float time = 0;
public void Initial()
public override void Show()
{
base.Show();
index = 0;
time = 0;
}
void Update()
{
time += Time.deltaTime;
@@ -82,7 +82,7 @@ public class FeedbackController : PFUIPanel
{
if (paths.ContainsValue(path))
{
Utils.showToast(gameObject, "图片已存在,请选择其他图片");
Utils.showToast(gameObject, "Picture already exists, please choose another picture");//图片已存在,请选择其他图片
return;
}
self.GetComponent<Image>().sprite = Utils.PngToSprite(path, 110, 110);
@@ -116,7 +116,7 @@ public class FeedbackController : PFUIPanel
}
else
{
Utils.showToast(gameObject, "已提交", type: 1);
Utils.showToast(gameObject, "Submitted", type: 1);//已提交
}
}
// Update is called once per frame
@@ -50,7 +50,7 @@ public class QuickLoginUser : MonoBehaviour
{
top.GetComponent<LoginController>().SaveInfo(r.data);
App.CurrentUser = r.data;
App.rideSetting.sensitivity = App.CurrentUser.Sensitivity;
SceneManager.LoadScene("MainScene");
}
else
@@ -99,7 +99,16 @@ public class BigMapController : PFUIPanel
content = panel.Find("Scroll View").Find("Viewport").Find("Content").gameObject;
var input = panel.Find("InputField");
base.SetRounded(input, 20f);
input.GetComponent<InputField>().onEndEdit.AddListener((text) =>
{
if (Input.GetKeyDown(KeyCode.Return))
{
this.Search(null);
}
});
keyword = input.Find("Text").GetComponent<Text>();
var searchBtn = input.Find("Search").gameObject;
UIManager.AddEvent(searchBtn, EventTriggerType.PointerClick, Search);
@@ -141,22 +150,27 @@ public class BigMapController : PFUIPanel
}
private void Search(BaseEventData e)
private async void Search(BaseEventData e)
{
if (string.IsNullOrWhiteSpace(keyword.text))
{
//yield return null;
return;
}
Debug.Log(keyword.text);
//UIManager.ShowLoadingDialogBox();
//Utils.showLoading(this.gameObject);
var infoStr = mapboxApi.GetAddressInfo(keyword.text);
//Debug.Log(info);
UIManager.ShowLoadingDialogBox();
var infoStr = await mapboxApi.GetAddressInfo(keyword.text);
//Debug.Log(infoStr);
var info = Newtonsoft.Json.Linq.JObject.Parse(infoStr);
var center = (info["features"] as JArray).First()["center"];
mapManager.UpdateMap(new Vector2d(Convert.ToDouble(center[1]), Convert.ToDouble(center[0])));
//mapManager.SetCenterLatitudeLongitude(new Vector2d(31.325053, 120.623564));
//mapManager.UpdateMap(new Vector2d(31.325053, 120.623564));
UIManager.HideLoadingDialogBox();
}
private void MapManager_OnInitialized()
@@ -6,6 +6,7 @@ using DG.Tweening;
using UnityEngine.UI;
using Assets.Scripts.Apis;
using Newtonsoft.Json.Linq;
using Assets.Scripts;
public class EarthController : PFUIPanel
{
@@ -21,11 +22,21 @@ public class EarthController : PFUIPanel
private GameObject hotPanel;
private GameObject content;
private Object itemObject;
Transform rootPanel;
Canvas canvas;
float time = 0f;
bool showSummary = false;
Vector2 latlonCenter;
protected override void Awake()
{
base.Awake();
mapApi = new MapApi();
canvas = this.transform.Find("Canvas").GetComponent<Canvas>();
canvas.worldCamera = Camera.main;
rootPanel = this.transform.Find("Canvas").Find("Panel");
map = WorldMapGlobe.instance;
map.showProvinces = true;
map.showCities = true;
@@ -45,8 +56,7 @@ public class EarthController : PFUIPanel
protected override void Start()
{
itemObject = Resources.Load("UI/Prefab/BigMap/Item");
var rootPanel = this.transform.Find("Canvas").Find("Panel");
var panel = rootPanel.Find("Panel");
SetRounded(panel, 60);
@@ -111,11 +121,14 @@ public class EarthController : PFUIPanel
Province.text = province.name;
ShowSummary(province.latlonCenter);
latlonCenter = province.latlonCenter;
time = 0f;
showSummary = true;
//ShowSummary(province.latlonCenter);
};
map.OnProvinceExit += (int provinceIndex, int regionIndex) =>
{
showSummary = false;
};
map.OnProvinceClick += (int provinceIndex, int regionIndex) =>
{
@@ -188,7 +201,7 @@ public class EarthController : PFUIPanel
private void Map_OnClick(Vector3 sphereLocation, int mouseButtonIndex)
{
Debug.Log("click");
//Debug.Log("click");
Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation);
Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y);
@@ -211,8 +224,18 @@ public class EarthController : PFUIPanel
void Update()
{
//var zoom = map.GetZoomLevel();
//Debug.Log(zoom);
if (showSummary)
{
time += Time.deltaTime;
if (time >= 0.2)
{
ShowSummary(latlonCenter);
showSummary = false;
}
}
//Debug.Log(showSummary + "," + time);
}
public void Show(double lat, double lon)
@@ -171,7 +171,7 @@ public class EditUserController : PFUIPanel
var result = await new UserApi().Login("13115011550", "laozhong", "");
App.CurrentUser = result.data;
}
async Task LoadDataSync()
void LoadDataSync()
{
//if (!App.FromLogin)
//{
@@ -246,6 +246,7 @@ public class EditUserController : PFUIPanel
{
base.Show();
LoadDataSync();
App.isChanged = false;
}
private void Switch(BaseEventData arg0)
{
@@ -276,58 +277,64 @@ public class EditUserController : PFUIPanel
mDayDropdown.AddOptions(list);
}
async void Save(BaseEventData e)
void Save(BaseEventData e)
{
var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser));
user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem));
user.Sex = mSexDropdown.SelectedItem == "男" ? 1 : 2;
user.Nickname = mNickName.Text;
user.Country = UIManager.Instance.loginRegOptions.GetCountryName(mConutryDropdown.SelectedIndex);
var errorList = new List<object>();
if (string.IsNullOrEmpty(mNickName.Text)) errorList.Add(new { Field = "Nickname", ErrMsg = "请填写昵称" });
if (string.IsNullOrEmpty(mFTP.Text)) errorList.Add(new { Field="FTP", ErrMsg="请填写FTP" });
if (string.IsNullOrEmpty(mHeight.Text)) errorList.Add(new { Field = "Height", ErrMsg = "请填写身高" });
if (string.IsNullOrEmpty(mWeight.Text)) errorList.Add(new { Field = "Weight", ErrMsg = "请填写体重" });
if (string.IsNullOrEmpty(mMHR.Text)) errorList.Add(new { Field = "MaxHeartRate", ErrMsg = "请填写最大心率" });
if (string.IsNullOrEmpty(mBW.Text)) errorList.Add(new { Field = "BicycleWeight", ErrMsg = "请填写车重" });
if (string.IsNullOrEmpty(mWD.Text)) errorList.Add(new { Field = "WheelDiameter", ErrMsg = "请填写轮径" });
if (errorList.Count > 0)
{
Utils.SetValidate(dict, JArray.FromObject(errorList));
Utils.showToast(gameObject, "请填写相关信息");
return;
}
user.FTP = int.Parse(mFTP.Text);
user.Height = int.Parse(mHeight.Text);
user.Weight = int.Parse(mWeight.Text);
user.MaxHeartRate = int.Parse(mMHR.Text);
user.BicycleWeight = int.Parse(mBW.Text);
user.WheelDiameter = int.Parse(mWD.Text);
user.Unit = mUnitDropdown.SelectedIndex;
user.Contact = mName.Text;
user.ContactPhone = mPhone.Text;
user.ContactAddress = mAddr.Text;
var result = await userApi.Update(user);
if (result.result == false)
{
Utils.SetValidate(dict, JArray.FromObject(result.data));
Utils.showToast(gameObject, result.errMsg);
//UIManager.ShowAlert(result.errMsg);
}
else
{
App.CurrentUser = user;
var userinfos = UIManager.Instance.userInfos;
var i = userinfos.FindIndex(x => x.Id == App.CurrentUser.Id);
if (i != -1)
{
userinfos[i].NickName = user.Nickname;
UIManager.Instance.userInfos = userinfos;
}
Utils.showToast(gameObject, "Success", type: 1);
//UIManager.ShowAlert("Success");
}
LoadDataSync();
UIManager.ShowConfirm("Confirm", "Are you sure to edit?", async () =>
{
var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser));
user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem));
user.Sex = mSexDropdown.SelectedItem == "男" ? 1 : 2;
user.Nickname = mNickName.Text;
user.Country = UIManager.Instance.loginRegOptions.GetCountryName(mConutryDropdown.SelectedIndex);
var errorList = new List<object>();
if (string.IsNullOrEmpty(mNickName.Text)) errorList.Add(new { Field = "Nickname", ErrMsg = "请填写昵称" });
if (string.IsNullOrEmpty(mFTP.Text)) errorList.Add(new { Field = "FTP", ErrMsg = "请填写FTP" });
if (string.IsNullOrEmpty(mHeight.Text)) errorList.Add(new { Field = "Height", ErrMsg = "请填写身高" });
if (string.IsNullOrEmpty(mWeight.Text)) errorList.Add(new { Field = "Weight", ErrMsg = "请填写体重" });
if (string.IsNullOrEmpty(mMHR.Text)) errorList.Add(new { Field = "MaxHeartRate", ErrMsg = "请填写最大心率" });
if (string.IsNullOrEmpty(mBW.Text)) errorList.Add(new { Field = "BicycleWeight", ErrMsg = "请填写车重" });
if (string.IsNullOrEmpty(mWD.Text)) errorList.Add(new { Field = "WheelDiameter", ErrMsg = "请填写轮径" });
if (errorList.Count > 0)
{
Utils.SetValidate(dict, JArray.FromObject(errorList));
Utils.showToast(gameObject, "Please fill in the information");//请填写相关信息
return;
}
user.FTP = int.Parse(mFTP.Text);
user.Height = int.Parse(mHeight.Text);
user.Weight = int.Parse(mWeight.Text);
user.MaxHeartRate = int.Parse(mMHR.Text);
user.BicycleWeight = int.Parse(mBW.Text);
user.WheelDiameter = int.Parse(mWD.Text);
user.Unit = mUnitDropdown.SelectedIndex;
user.Contact = mName.Text;
user.ContactPhone = mPhone.Text;
user.ContactAddress = mAddr.Text;
var result = await userApi.Update(user);
App.isChanged = false;
if (result.result == false)
{
Utils.SetValidate(dict, JArray.FromObject(result.data));
Utils.showToast(gameObject, result.errMsg);
//UIManager.ShowAlert(result.errMsg);
}
else
{
App.CurrentUser = user;
var userinfos = UIManager.Instance.userInfos;
var i = userinfos.FindIndex(x => x.Id == App.CurrentUser.Id);
if (i != -1)
{
userinfos[i].NickName = user.Nickname;
UIManager.Instance.userInfos = userinfos;
}
Utils.showToast(gameObject, "Success", type: 1);
//UIManager.ShowAlert("Success");
}
LoadDataSync();
});
//App.CurrentUser = user;
//UIManager.ShowAlert("result.errMsg");
@@ -335,6 +342,7 @@ public class EditUserController : PFUIPanel
async void ChangeAvatar(string path)
{
var r = await userApi.Update(App.CurrentUser, path);
App.isChanged = false;
if (r.result)
{
var img = JObject.FromObject(r.data).Value<string>("WxHeadImg");
@@ -358,6 +366,18 @@ public class EditUserController : PFUIPanel
}
void Cancel(BaseEventData e)
{
UIManager.ShowPrePanel();
if (App.isChanged)
{
UIManager.ShowConfirm("Tips", "It is detected that you have modified, do you want to give up and return?", () =>
{
UIManager.ShowPrePanel();
UIManager.CloseConfirm();
});
}
else
{
UIManager.ShowPrePanel();
}
}
}
@@ -100,6 +100,10 @@ public class HomeController : PFUIPanel
{
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
}
else
{
userInfo.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
}
Utils.DisplayImage(StartCoroutine, userInfo.Find("Avatar").GetComponent<RawImage>(), App.CurrentUser.WxHeadImg);
userInfo.Find("Country").GetComponent<RawImage>().texture = UIManager.Instance.loginRegOptions.GetCountryImageByName(App.CurrentUser.Country);
@@ -84,10 +84,19 @@ public class UserInfoController : PFUIPanel
infoPanel.Find("Weight").Find("Value").GetComponent<Text>().text = $"{user.Weight}KG";
infoPanel.Find("BW").Find("Value").GetComponent<Text>().text = $"{user.BicycleWeight}KG";
infoPanel.Find("WD").Find("Value").GetComponent<Text>().text = $"{user.WheelDiameter}MM";
//infoPanel.Find("Ftp").Find("Time").GetComponent<Text>().text = user.LastUpdateFtpTime.ToString("yyyy-MM-dd");
//infoPanel.Find("MHR").Find("Time").GetComponent<Text>().text = user.MaxHeartRate.ToString();
//infoPanel.Find("Weight").Find("Time").GetComponent<Text>().text = user.LastUpdateWeightTime.ToString("yyyy-MM-dd");
//infoPanel.Find("BW").Find("Time").GetComponent<Text>().text = user.LastUpdateBicycleWeightTime.ToString("yyyy-MM-dd");
//infoPanel.Find("WD").Find("Time").GetComponent<Text>().text = $"{user.WheelDiameter}MM";
if (user.Sex == 2)
{
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/woman");
}
else
{
infoPanel.Find("SexIcon").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/man");
}
summaryPanel.Find("Number").Find("Value").GetComponent<Text>().text = summary.Count.ToString();
summaryPanel.Find("Time").Find("Value").GetComponent<Text>().text = summary.TotalTicks.ToString();
summaryPanel.Find("KM").Find("Value").GetComponent<Text>().text = summary.TotalDistance.ToString();
@@ -89,35 +89,57 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
right.Find("Value").GetComponent<Text>().text = result.Ranking.ToString();
}
right.gameObject.SetActive(true);
gameObject.GetComponent<Button>().onClick.AddListener(() =>
{
Application.OpenURL(result.ViewUrl);
});
this.index = index;
}
private void Delete()
{
//throw new NotImplementedException();
UIManager.ShowAlert("暂未实现");
UIManager.ShowConfirm("Delete", "Delete this record?", async () =>
{
var r = await ConfigHelper.mapApi.DeleteRecord(routeResult.Id);
UIManager.CloseConfirm();
if (r.result)
{
DestroyImmediate(gameObject);
}
else
{
Utils.showToast(gameObject, r.errMsg);
}
});
}
private void GoReRide()
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
App.routeResult.ContinueCyclingParam = null;
SceneManager.LoadScene("Ride");
UIManager.ShowConfirm("ReRide", "Ride again?", () =>
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
App.routeResult.ContinueCyclingParam = null;
SceneManager.LoadScene("Ride");
});
}
private void GoContinue()
{
if (routeResult.ContinueCyclingParam != null)
UIManager.ShowConfirm("Continue", "Continue riding?", () =>
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
SceneManager.LoadScene("Ride");
}
if (routeResult.ContinueCyclingParam != null)
{
App.RouteIdParam = routeResult.RouteId;
App.routeResult = routeResult;
SceneManager.LoadScene("Ride");
}
});
}
void SetButtonColor(bool f)
{
if (index == 0)
if (index == 0 && routeResult!=null)
{
if (f)
{
@@ -166,6 +188,7 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
}
titleColor = "#414251";
SetButtonColor(false);
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
}
public void OnPointerEnter(PointerEventData eventData)
@@ -192,5 +215,6 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
}
titleColor = "#5c5c6e";
SetButtonColor(true);
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
}
}
+44 -2
View File
@@ -142,6 +142,7 @@ public class UIManager : MonoBehaviour
stack = new Stack<PFUIPanel>();
loginRegOptions = new LoginRegOptions();
var userInfosJson = PlayerPrefs.GetString("UserInfos");
Debug.Log(userInfosJson);
userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
if (userInfos == null) userInfos = new List<QUserInfo>();
@@ -190,7 +191,7 @@ public class UIManager : MonoBehaviour
{
if (internalComponent == null)
{
UnityEngine.Object @object = Resources.Load("UI/Prefab/" + prefabName);
UnityEngine.Object @object = Resources.Load("UI/Prefab/Common/" + prefabName);
if (@object != null)
{
GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate(@object, base.transform.parent, false);
@@ -352,9 +353,44 @@ public class UIManager : MonoBehaviour
UIManager.Show(UIManager.Instance.EditUserPanel, UIManager.Instance.MainPanel);
}
//LoadingPf loading;
public static void ShowLoadingDialogBox()
{
if (UIManager.Instance == null)
{
return;
}
//if(UIManager.Instance.loading == null)
//{
// UIManager.Instance.loading = UIManager.Instance.GetInstance<LoadingPf>("Loading", ref UIManager.Instance.loading);
// UIManager.Instance.loading.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
// //var rect = UIManager.Instance.loading.GetComponent<RectTransform>().rect;
// //rect.width = 154;
// //rect.height = 111;
// UIManager.Instance.loading.GetComponent<RectTransform>().sizeDelta = new Vector2(154, 111);
// //var rrr = UIManager.Instance.loading.GetComponent<RectTransform>();
// UIManager.Instance.loading.Initial();
// UIManager.Show(UIManager.Instance.loading, null, true);
//}
//else
//{
// UIManager.Instance.loading.Show();
//}
Utils.showLoading(UIManager.Instance.ModalsPanel.gameObject);
}
public static void HideLoadingDialogBox()
{
if (UIManager.Instance == null)
{
return;
}
Utils.hideLoading(UIManager.Instance.ModalsPanel.gameObject);
}
public static void ShowMapListPanel()
{
UIManager.Show(UIManager.Instance.MapListPanel, UIManager.Instance.MainPanel);
@@ -536,7 +572,13 @@ public class UIManager : MonoBehaviour
UIManager.Instance.confirm.Set(title, content, action);
}
}
public static void CloseConfirm()
{
if (UIManager.Instance.confirm != null)
{
UIManager.Instance.confirm.Close();
}
}
public LoginRegOptions loginRegOptions { get; private set; }
private List<QUserInfo> _userInfos;
public List<QUserInfo> userInfos
+8 -8
View File
@@ -123,8 +123,9 @@ namespace Assets.Scripts
public static void showToast(GameObject game,string text,int duration = 1,int type = 0)
{
//type 0错误 1正确
var parent = Utils.FindUpParent(game.transform);
var toast = parent.Find("ToastContainer");
var parent = UIManager.Instance.ModalsPanel;
if (parent == null) return;
var toast = parent.transform.Find("ToastContainer");
if (toast != null)
{
MonoBehaviour.DestroyImmediate(toast.gameObject);
@@ -132,7 +133,7 @@ namespace Assets.Scripts
var newToast = MonoBehaviour.Instantiate(Resources.Load<GameObject>("UI/Prefab/ToastContainer"));
newToast.name = "ToastContainer";
newToast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
newToast.transform.parent = parent;
newToast.transform.parent = parent.transform;
toast = newToast.transform;
var toastStyle = toastDict[type].Split('|');
toast.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>(toastStyle[0]);
@@ -156,8 +157,7 @@ namespace Assets.Scripts
newLoading.transform.parent = parent;
loading = newLoading.transform;
}
loading.GetComponent<LoadingPf>().Initial();
loading.gameObject.SetActive(true);
loading.GetComponent<LoadingPf>().Show();
}
public static void showLoadingExtension(this GameObject game)
@@ -171,8 +171,7 @@ namespace Assets.Scripts
newLoading.transform.parent = game.transform;
loading = newLoading.transform;
}
loading.GetComponent<LoadingPf>().Initial();
loading.gameObject.SetActive(true);
loading.GetComponent<LoadingPf>().Show();
}
public static void hideLoading(this GameObject game)
{
@@ -180,7 +179,8 @@ namespace Assets.Scripts
var loading = parent.Find("Loading");
if (loading != null)
{
loading.gameObject.SetActive(false);
//loading.gameObject.SetActive(false);
loading.GetComponent<LoadingPf>().Close();
}
}
/*删除父亲节点下的所有孩子*/