设置页面,调些细节
This commit is contained in:
1 parent
4896fab824
commit
bb4fabc833
23 files changed
+5528
-1756
No files matched your search
@@ -9,13 +9,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class ConfigHelper
|
||||
public static class ConfigHelper
|
||||
{
|
||||
public static string Host = App.Host;
|
||||
|
||||
public static string AppVersion = App.AppVersion;
|
||||
|
||||
public static UserApi userApi = new UserApi();
|
||||
public static UserApi _userApi;
|
||||
public static UserApi userApi
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_userApi == null) _userApi = new UserApi();
|
||||
return _userApi;
|
||||
}
|
||||
}
|
||||
public static MapApi mapApi = new MapApi();
|
||||
public static MapInterruptRecordApi mapInterruptRecordApi = new MapInterruptRecordApi();
|
||||
public static ThirdPartApi thirdPartApi = new ThirdPartApi();
|
||||
|
||||
@@ -9,6 +9,7 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
@@ -231,22 +232,25 @@ public class LoginController : MonoBehaviour
|
||||
if (loginContainer != null)
|
||||
{
|
||||
var returnQuick = loginContainer.Find("returnQuick").GetComponent<Button>();
|
||||
returnQuick.onClick.AddListener(ReturnQuick);
|
||||
UIManager.AddEvent(returnQuick.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
ReturnQuick();
|
||||
});
|
||||
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");
|
||||
if (gou.gameObject.activeSelf)
|
||||
{
|
||||
gou.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
gou.gameObject.SetActive(true);
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(remember.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
var gou = remember.transform.Find("Gou");
|
||||
if (gou.gameObject.activeSelf)
|
||||
{
|
||||
gou.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
gou.gameObject.SetActive(true);
|
||||
}
|
||||
});
|
||||
var wechatLogin = loginContainer.Find("otherContainer").Find("Wechat").GetComponent<Button>();
|
||||
wechatLogin.onClick.AddListener(() =>
|
||||
{
|
||||
@@ -277,26 +281,32 @@ public class LoginController : MonoBehaviour
|
||||
if (signContainer != null)
|
||||
{
|
||||
var loginr2 = signContainer.Find("loginr2").GetComponent<Button>();
|
||||
loginr2.onClick.AddListener(goLoginReturn2);
|
||||
UIManager.AddEvent(loginr2.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
goLoginReturn2();
|
||||
});
|
||||
}
|
||||
if (exit != null)
|
||||
{
|
||||
exit.onClick.AddListener(() => Application.Quit());
|
||||
UIManager.AddEvent(exit.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
Application.Quit();
|
||||
});
|
||||
}
|
||||
|
||||
wxLogin1 = mainContent.Find("FormContainer-Login").Find("Mask").Find("FormContainer-wx1");
|
||||
if (wxLogin1 != null)
|
||||
{
|
||||
wxLogin1.Find("Image").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
wxLock = true;
|
||||
wxBrowser.Url = "chrome://version/";
|
||||
wxLogin1.DOLocalMoveY(-573, 0.3f).onComplete = () =>
|
||||
{
|
||||
wxLock = false;
|
||||
wxLogin1.gameObject.SetActive(false);
|
||||
};
|
||||
});
|
||||
UIManager.AddEvent(wxLogin1.Find("Image").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
wxLock = true;
|
||||
wxBrowser.Url = "chrome://version/";
|
||||
wxLogin1.DOLocalMoveY(-573, 0.3f).onComplete = () =>
|
||||
{
|
||||
wxLock = false;
|
||||
wxLogin1.gameObject.SetActive(false);
|
||||
};
|
||||
});
|
||||
wxBrowser = wxLogin1.Find("Browser (GUI)").GetComponent<Browser>();
|
||||
if (wxBrowser != null)
|
||||
{
|
||||
@@ -323,14 +333,14 @@ public class LoginController : MonoBehaviour
|
||||
wxLogin2 = mainContent.Find("FormContainer-wx2");
|
||||
if (wxLogin2!=null)
|
||||
{
|
||||
wxLogin2.Find("return").GetComponent<Button>().onClick.AddListener(() => {
|
||||
wxLogin2.gameObject.SetActive(false);
|
||||
//wxLogin3.gameObject.SetActive(false);
|
||||
pageNums = 4;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
StartScrollPanel(1);
|
||||
});
|
||||
|
||||
UIManager.AddEvent(wxLogin2.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
wxLogin2.gameObject.SetActive(false);
|
||||
//wxLogin3.gameObject.SetActive(false);
|
||||
pageNums = 4;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
StartScrollPanel(1);
|
||||
});
|
||||
wxLogin2.Find("Next").GetComponent<Button>().onClick.AddListener(()=>
|
||||
{
|
||||
this.goSign(false);
|
||||
@@ -339,24 +349,29 @@ public class LoginController : MonoBehaviour
|
||||
wxLogin3 = mainContent.Find("FormContainer-wx3");
|
||||
if (wxLogin3 != null)
|
||||
{
|
||||
wxLogin3.Find("return").GetComponent<Button>().onClick.AddListener(() => {
|
||||
if (signContainer.gameObject.activeSelf)
|
||||
{
|
||||
StartScrollPanel(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
signContainer.gameObject.SetActive(true);
|
||||
pageNums = 4;
|
||||
//wxLogin3.gameObject.SetActive(false);
|
||||
StartScrollPanel(1);
|
||||
}
|
||||
});
|
||||
wxLogin3.Find("rememberButton").GetComponent<Button>().onClick.AddListener(()=>
|
||||
{
|
||||
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
|
||||
gou.SetActive(!gou.activeSelf);
|
||||
});
|
||||
UIManager.AddEvent(wxLogin3.Find("return").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
if (signContainer.gameObject.activeSelf)
|
||||
{
|
||||
StartScrollPanel(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
signContainer.gameObject.SetActive(true);
|
||||
pageNums = 4;
|
||||
//wxLogin3.gameObject.SetActive(false);
|
||||
StartScrollPanel(1);
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(wxLogin3.Find("rememberButton").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
var gou = wxLogin3.Find("rememberButton").Find("Gou").gameObject;
|
||||
gou.SetActive(!gou.activeSelf);
|
||||
});
|
||||
//wxLogin3.Find("rememberButton").GetComponent<Button>().onClick.AddListener(()=>
|
||||
//{
|
||||
|
||||
//});
|
||||
wxLogin3.Find("Next").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
goMain(wxLogin3.Find("rememberButton").Find("Gou"));
|
||||
@@ -368,14 +383,22 @@ public class LoginController : MonoBehaviour
|
||||
toolContainer = transform.Find("Panel").Find("ToolContainer");
|
||||
if (toolContainer != null)
|
||||
{
|
||||
toolContainer.Find("Setting").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
UIManager.ShowSettingModal();
|
||||
});
|
||||
toolContainer.Find("Msg").GetComponent<Button>().onClick.AddListener(() =>
|
||||
UIManager.AddEvent(toolContainer.Find("Setting").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
UIManager.ShowSettingModal();
|
||||
});
|
||||
//toolContainer.Find("Setting").GetComponent<Button>().onClick.AddListener(() =>
|
||||
//{
|
||||
// UIManager.ShowSettingModal();
|
||||
//});
|
||||
UIManager.AddEvent(toolContainer.Find("Msg").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
UIManager.ShowNewsModal();
|
||||
});
|
||||
//toolContainer.Find("Msg").GetComponent<Button>().onClick.AddListener(() =>
|
||||
//{
|
||||
// UIManager.ShowNewsModal();
|
||||
//});
|
||||
}
|
||||
}
|
||||
private void AdjustWxQrCode()
|
||||
@@ -769,6 +792,7 @@ public class LoginController : MonoBehaviour
|
||||
userInfos.Remove(u);
|
||||
}
|
||||
UIManager.Instance.userInfos = userInfos;
|
||||
UIManager.Instance.userInfoIndex = 0;
|
||||
}
|
||||
App.CurrentUser = data;
|
||||
//App.CurrentUser = new UserModel
|
||||
@@ -786,8 +810,8 @@ public class LoginController : MonoBehaviour
|
||||
}
|
||||
public void SaveInfo(UserResultModel data)
|
||||
{
|
||||
var u = userInfos.Find(x => x.Id == data.Id);
|
||||
if (u == null)
|
||||
var index = userInfos.FindIndex(x => x.Id == data.Id);
|
||||
if (index == -1)
|
||||
{
|
||||
userInfos.Add(new QUserInfo
|
||||
{
|
||||
@@ -796,19 +820,27 @@ public class LoginController : MonoBehaviour
|
||||
Avatar = data.WxHeadImg,
|
||||
Cookie = data.cookie
|
||||
});
|
||||
index = userInfos.Count - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfos.Insert(0, new QUserInfo
|
||||
{
|
||||
Id = data.Id,
|
||||
NickName = data.Nickname,
|
||||
Avatar = data.WxHeadImg,
|
||||
Cookie = data.cookie
|
||||
});
|
||||
userInfos.Remove(u);
|
||||
var u = userInfos[index];
|
||||
u.Id = data.Id;
|
||||
u.NickName = data.Nickname;
|
||||
u.Avatar = data.WxHeadImg;
|
||||
u.Cookie = data.cookie;
|
||||
//userInfos.Insert(0, new QUserInfo
|
||||
//{
|
||||
// Id = data.Id,
|
||||
// NickName = data.Nickname,
|
||||
// Avatar = data.WxHeadImg,
|
||||
// Cookie = data.cookie
|
||||
//});
|
||||
//userInfos.Remove(u);
|
||||
}
|
||||
UIManager.Instance.userInfos = userInfos;
|
||||
UIManager.Instance.userInfoIndex = index;
|
||||
//PlayerPrefs.SetInt("UserInfoIndex", index);
|
||||
}
|
||||
async void Submit()
|
||||
{
|
||||
@@ -844,6 +876,13 @@ public class LoginController : MonoBehaviour
|
||||
{
|
||||
loginForm.password.ActivateInputField();
|
||||
}
|
||||
if (Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Return))
|
||||
{
|
||||
if (loginForm != null && !string.IsNullOrEmpty(loginForm.email.text) && !string.IsNullOrEmpty(loginForm.password.text))
|
||||
{
|
||||
Submit();
|
||||
}
|
||||
}
|
||||
if (startCaptcha)
|
||||
{
|
||||
CaptchaTimerTick();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PFUISlider : MonoBehaviour
|
||||
{
|
||||
private Text text;
|
||||
private Slider slider;
|
||||
private void Awake()
|
||||
{
|
||||
text = transform.Find("Text").GetComponent<Text>();
|
||||
slider = transform.GetComponent<Slider>();
|
||||
text.text = $"{(slider.value * 100).ToString("#0")}%";
|
||||
slider.onValueChanged.AddListener((f) =>
|
||||
{
|
||||
text.text = $"{(f * 100).ToString("#0")}%";
|
||||
});
|
||||
}
|
||||
// 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: e288f268809db2a4bbc2b31a9fe797e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -47,7 +47,9 @@ public class QuickLoginScroll : MonoBehaviour
|
||||
}
|
||||
//scroll.horizontalNormalizedPosition = 0;
|
||||
Canvas.ForceUpdateCanvases();
|
||||
scroll.horizontalNormalizedPosition = contentSize/2;
|
||||
var i = PlayerPrefs.GetInt("UserInfoIndex");
|
||||
Debug.Log($"51 {i}");
|
||||
scroll.horizontalNormalizedPosition = contentSize/2+i*contentSize;
|
||||
SetColor();
|
||||
}
|
||||
void goLeft()
|
||||
|
||||
@@ -84,6 +84,7 @@ public class QuickLoginUser : MonoBehaviour
|
||||
var userInfos = UIManager.Instance.userInfos;
|
||||
userInfos.RemoveAt(index);
|
||||
UIManager.Instance.userInfos = userInfos;
|
||||
UIManager.Instance.userInfoIndex = 0;
|
||||
}
|
||||
|
||||
public void setActive()
|
||||
|
||||
@@ -59,9 +59,8 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
|
||||
// //transform.localPosition.Set(transform.localPosition.x, localY.Value, transform.localPosition.z);
|
||||
// //transform.DOLocalMoveY(localY.Value, 0.5f);
|
||||
//});
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
Debug.Log(123);
|
||||
UIManager.ShowMapDetailPanel(myMap.Id);
|
||||
});
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewsController : PFUIPanel
|
||||
@@ -13,7 +14,7 @@ public class NewsController : PFUIPanel
|
||||
exit = transform.Find("Main").Find("Exit");
|
||||
if (exit != null)
|
||||
{
|
||||
exit.GetComponent<Button>().onClick.AddListener(() =>
|
||||
UIManager.AddEvent(exit.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
Close();
|
||||
});
|
||||
|
||||
@@ -200,21 +200,20 @@ public class EditUserController : PFUIPanel
|
||||
mPhone.Text = currentUser.ContactPhone;
|
||||
mAddr.Text = currentUser.ContactAddress;
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
mConutryDropdown.ClearOptions();
|
||||
mConutryDropdown.AddOptions(UIManager.Instance.loginRegOptions.countrys);
|
||||
mConutryDropdown.SelectIndex(UIManager.Instance.loginRegOptions.countryDefaultValue);
|
||||
mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
|
||||
UIManager.Instance.loginRegOptions.GetCountryImage(UIManager.Instance.loginRegOptions.countryDefaultValue);
|
||||
mConutryDropdown.OnValueChange = (int index) =>
|
||||
{
|
||||
mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
|
||||
UIManager.Instance.loginRegOptions.GetCountryImage(index);
|
||||
};
|
||||
mConutryDropdown.SelectValue(App.CurrentUser.Country);
|
||||
//mConutryDropdown.transform.Find("RawImage").GetComponent<RawImage>().texture =
|
||||
// UIManager.Instance.loginRegOptions.GetCountryImage(UIManager.Instance.loginRegOptions.countryDefaultValue);
|
||||
var rect = ((RectTransform)mHeadImage.transform).rect;
|
||||
SetRounded(mHeadImage.transform, rect.height);
|
||||
UIManager.AddEvent(mSaveButton.gameObject, EventTriggerType.PointerClick, Save);
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
@@ -46,7 +47,7 @@ public class MapListController : PFUIPanel
|
||||
//{
|
||||
// hardSelector.onValueChanged.AddListener(ChangeHard);
|
||||
//}
|
||||
ApiBase.SetCookie("15A37DF28842CBA8E4E550BFA24186C8222D392F3EE18D9E95A49CC32796D2E3F6E40385C6A114942546EE1DD793DF34880DE48090B91AD2460EB887B59664BB3965F3371DDA1F1401EC7F27C5A1084566E47069F12CB6BBC0BC7A84ADC5582B");
|
||||
//ApiBase.SetCookie("15A37DF28842CBA8E4E550BFA24186C8222D392F3EE18D9E95A49CC32796D2E3F6E40385C6A114942546EE1DD793DF34880DE48090B91AD2460EB887B59664BB3965F3371DDA1F1401EC7F27C5A1084566E47069F12CB6BBC0BC7A84ADC5582B");
|
||||
btnMapMode = this.transform.Find("SwitchMode").gameObject;
|
||||
SetRounded(btnMapMode.transform, 64);
|
||||
UIManager.AddEvent(btnMapMode, EventTriggerType.PointerClick, (e) =>
|
||||
@@ -104,6 +105,10 @@ public class MapListController : PFUIPanel
|
||||
GetList();
|
||||
if (scroll != null)
|
||||
{
|
||||
//scroll.GetComponent<ScrollRect>().onValueChanged.AddListener((v) =>
|
||||
//{
|
||||
// OnEndDrag(null);
|
||||
//});
|
||||
UIManager.AddEvent(scroll, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
//UIManager.AddEvent(transform.Find("Panel").Find("Panel"))
|
||||
@@ -146,10 +151,14 @@ public class MapListController : PFUIPanel
|
||||
searchInput = transform.Find("Panel").Find("Panel").Find("SearchInput");
|
||||
if (searchInput != null)
|
||||
{
|
||||
searchInput.GetComponent<InputField>().onEndEdit.AddListener((s) =>
|
||||
{
|
||||
Debug.Log(Input.GetKeyUp(KeyCode.A));
|
||||
//onEndEdit(s);
|
||||
});
|
||||
searchInput.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
ftname = searchInput.GetComponent<InputField>().text;
|
||||
Refresh();
|
||||
onEndEdit();
|
||||
});
|
||||
}
|
||||
sorts = transform.Find("Panel").Find("Panel").Find("FilterOptions");
|
||||
@@ -187,7 +196,15 @@ public class MapListController : PFUIPanel
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void onEndEdit()
|
||||
{
|
||||
var t = searchInput.GetComponent<InputField>().text;
|
||||
if (!string.IsNullOrEmpty(t))
|
||||
{
|
||||
ftname = t;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 绑定头像
|
||||
/// </summary>
|
||||
@@ -213,13 +230,13 @@ public class MapListController : PFUIPanel
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
var scrollrect = scroll.GetComponent<ScrollRect>();
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
if (scrollrect.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= 1)
|
||||
if (scrollrect.verticalNormalizedPosition >= (pageIndex == 0 ? 1.2:1))
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
@@ -281,6 +298,7 @@ public class MapListController : PFUIPanel
|
||||
{
|
||||
content.transform.DestroyChildren();
|
||||
pageIndex = 0;
|
||||
isEnd = false;
|
||||
GetList();
|
||||
}
|
||||
void ResetList()
|
||||
@@ -291,9 +309,29 @@ public class MapListController : PFUIPanel
|
||||
Refresh();
|
||||
}
|
||||
// Update is called once per frame
|
||||
bool startMouse = false;
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
if (scroll.GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
if (Input.GetKey(KeyCode.KeypadEnter) || Input.GetKey(KeyCode.Return))
|
||||
{
|
||||
onEndEdit();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
|
||||
@@ -11,9 +11,8 @@ public class UserInfoController : PFUIPanel
|
||||
// Start is called before the first frame update
|
||||
UserApi userApi;
|
||||
Transform infoPanel,summaryPanel;
|
||||
protected override void Start()
|
||||
protected override void Awake()
|
||||
{
|
||||
userApi = ConfigHelper.userApi;
|
||||
this.transform.localPosition = new Vector3(0, 0, 0);
|
||||
|
||||
Button exitBtn = this.transform.Find("InfoPanel").Find("Button").GetComponent<Button>();
|
||||
@@ -42,16 +41,20 @@ public class UserInfoController : PFUIPanel
|
||||
// UIManager.ShowEditUserPanel();
|
||||
//});
|
||||
summaryPanel = transform.Find("SummaryPanel");
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
Load();
|
||||
}
|
||||
async void Load()
|
||||
void Load()
|
||||
{
|
||||
//if (!App.FromLogin)
|
||||
//{
|
||||
// var result = await userApi.Login("15651831367", "123456", "");
|
||||
// App.CurrentUser = result.data;
|
||||
//}
|
||||
var r = userApi.GetSummary();
|
||||
var r = ConfigHelper.userApi.GetSummary();
|
||||
if (r.result)
|
||||
{
|
||||
var summary = r.data;
|
||||
|
||||
@@ -4,11 +4,26 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
public int AutoPause { set; get; }
|
||||
public float Sensitivity { set; get; }
|
||||
public int IMode { set; get; }
|
||||
public int Unit { set; get; }
|
||||
public float Volume { set; get; }
|
||||
public int WMode { set; get; }
|
||||
public int Language { set; get; }
|
||||
}
|
||||
public class SettingContoller : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
Transform exit;
|
||||
Button[] AutoPause, IMode, Unit, WMode, Language;
|
||||
Slider Sensitivity, Volume;
|
||||
Settings settings;
|
||||
protected override void Awake()
|
||||
{
|
||||
exit = transform.Find("Main").Find("Exit");
|
||||
@@ -20,27 +35,111 @@ public class SettingContoller : PFUIPanel
|
||||
//});
|
||||
UIManager.AddEvent(exit.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
UIManager.Instance.settings = settings;
|
||||
Close();
|
||||
});
|
||||
}
|
||||
var inner = transform.Find("Main").Find("Inner");
|
||||
AutoPause = new Button[]
|
||||
{
|
||||
inner.Find("AutoPause").Find("BtnOpen").GetComponent<Button>(),
|
||||
inner.Find("AutoPause").Find("BtnClose").GetComponent<Button>()
|
||||
};
|
||||
IMode = new Button[]
|
||||
{
|
||||
inner.Find("IMode").Find("BtnSimple").GetComponent<Button>(),
|
||||
inner.Find("IMode").Find("BtnFull").GetComponent<Button>()
|
||||
};
|
||||
Unit = new Button[]
|
||||
{
|
||||
inner.Find("Unit").Find("BtnMetric").GetComponent<Button>(),
|
||||
inner.Find("Unit").Find("BtnImperial").GetComponent<Button>()
|
||||
};
|
||||
WMode = new Button[]
|
||||
{
|
||||
inner.Find("WMode").Find("BtnWindow").GetComponent<Button>(),
|
||||
inner.Find("WMode").Find("BtnFull").GetComponent<Button>()
|
||||
};
|
||||
Language = new Button[]
|
||||
{
|
||||
inner.Find("Language").Find("BtnChinese").GetComponent<Button>(),
|
||||
inner.Find("Language").Find("BtnEnglish").GetComponent<Button>()
|
||||
};
|
||||
Sensitivity = inner.Find("Sensitivity").Find("Slider").GetComponent<Slider>();
|
||||
Volume = inner.Find("Volume").Find("Slider").GetComponent<Slider>();
|
||||
AddClick();
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
private void AddClick()
|
||||
{
|
||||
AddClick(WMode);
|
||||
AddClick(Unit);
|
||||
AddClick(IMode);
|
||||
AddClick(AutoPause);
|
||||
AddClick(Language);
|
||||
Sensitivity.onValueChanged.AddListener((f) => { settings.Sensitivity = f; });
|
||||
Volume.onValueChanged.AddListener((f) => { settings.Volume = f; });
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
settings = UIManager.Instance.settings;
|
||||
SetValue(WMode, settings.WMode,"WMode");
|
||||
SetValue(Unit, settings.Unit, "Unit");
|
||||
SetValue(IMode, settings.IMode, "IMode");
|
||||
SetValue(AutoPause, settings.AutoPause, "AutoPause");
|
||||
SetValue(Language, settings.Language, "Language");
|
||||
Sensitivity.value = settings.Sensitivity;
|
||||
Volume.value = settings.Volume;
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
void AddClick(Button[] buttons)
|
||||
{
|
||||
for (int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
int index = i;
|
||||
UIManager.AddEvent(buttons[i].gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
SetValue(buttons, index,buttons[index].transform.parent.name);
|
||||
});
|
||||
}
|
||||
}
|
||||
void SetValue(Button[] buttons, int value,string valueName)
|
||||
{
|
||||
for (int i = 0; i < buttons.Length; i++)
|
||||
{
|
||||
var b = buttons[i];
|
||||
if (i == value)
|
||||
{
|
||||
b.GetComponent<Image>().color = Utils.HexToColorHtml("#F93086");
|
||||
b.transform.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#FFFFFF");
|
||||
settings.GetType().GetProperty(valueName).SetValue(UIManager.Instance.settings,i);
|
||||
}
|
||||
else
|
||||
{
|
||||
b.GetComponent<Image>().color = Utils.HexToColorHtml("#414251");
|
||||
b.transform.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#9e9ead");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
var cg = this.GetComponent<CanvasGroup>();
|
||||
cg.alpha = 0;
|
||||
base.Show();
|
||||
|
||||
cg.DOFade(1f, 0.3f);
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,12 @@ public class UIManager : MonoBehaviour
|
||||
var userInfosJson = PlayerPrefs.GetString("UserInfos");
|
||||
userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
|
||||
if (userInfos == null) userInfos = new List<QUserInfo>();
|
||||
|
||||
var settingsJson = PlayerPrefs.GetString("Settings");
|
||||
settings = JsonConvert.DeserializeObject<Settings>(settingsJson);
|
||||
if (settings == null) settings = new Settings();
|
||||
|
||||
userInfoIndex = PlayerPrefs.GetInt("UserInfoIndex");
|
||||
collectDict = new Dictionary<bool, Sprite> {
|
||||
{ false,Resources.Load<Sprite>("Images/p-4灰")},
|
||||
{ true,Resources.Load<Sprite>("Images/p-4")},
|
||||
@@ -437,6 +443,32 @@ public class UIManager : MonoBehaviour
|
||||
}
|
||||
}
|
||||
public Dictionary<bool, Sprite> collectDict { get; private set; }
|
||||
private int _userInfoIndex;
|
||||
public int userInfoIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _userInfoIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
_userInfoIndex = value;
|
||||
PlayerPrefs.SetInt("UserInfoIndex", value);
|
||||
}
|
||||
}
|
||||
private Settings _settings;
|
||||
public Settings settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return _settings;
|
||||
}
|
||||
set
|
||||
{
|
||||
_settings = value;
|
||||
PlayerPrefs.SetString("Settings", JsonConvert.SerializeObject(value));
|
||||
}
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
UIManager.Instance = null;
|
||||
|
||||
@@ -168,5 +168,6 @@ namespace Assets.Scripts
|
||||
str = String.Concat(str, random.Next(10).ToString());
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user