加弹框。修改连接设备样式。

This commit is contained in:
suntao committed 2021-04-09 09:44:06 +08:00
1 parent 07feba912c
commit 5156473bb2
62 files changed
+4963 -5447

No files matched your search

+69 -8
View File
@@ -6,15 +6,13 @@ using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
namespace Assets.Scripts.UI.Control
{
public class PFUIDropdown : PFUIComponentBase
{
private int mSelectedIndex = -1;
private object mSelectedValue;
private int mSelectedIndex = 0;
public int SelectedIndex
{
get
@@ -23,15 +21,41 @@ namespace Assets.Scripts.UI.Control
}
}
public int Value
//public int Value
//{
// get
// {
// return this.GetComponent<Dropdown>().value;
// }
// set
// {
// this.GetComponent<Dropdown>().value = value;
// }
//}
public string SelectedItem
{
get
{
return this.GetComponent<Dropdown>().value;
if(this.mSelectedIndex >= 0)
{
return this.GetComponent<Dropdown>().options[this.mSelectedIndex].text;
}
return null;
}
}
private UnityAction<int> mOnValueChange;
public UnityAction<int> OnValueChange
{
get
{
return mOnValueChange;
}
set
{
this.GetComponent<Dropdown>().value = value;
mOnValueChange = value;
}
}
@@ -40,6 +64,14 @@ namespace Assets.Scripts.UI.Control
//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.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(OnDeselect));
this.GetComponent<Dropdown>().onValueChanged.AddListener(i => {
mSelectedIndex = i;
if (OnValueChange != null)
{
mOnValueChange(i);
}
});
}
public void OnSelect(BaseEventData eventData)
@@ -57,9 +89,38 @@ namespace Assets.Scripts.UI.Control
public void AddOptions(List<Dropdown.OptionData> options)
{
this.GetComponent<Dropdown>().AddOptions(options);
}
public void AddOptions(List<string> options)
{
this.GetComponent<Dropdown>().AddOptions(options);
}
public void ClearOptions()
{
this.GetComponent<Dropdown>().ClearOptions();
}
public void SelectIndex(int index)
{
this.GetComponent<Dropdown>().value = index;
this.mSelectedIndex = index;
}
public void SelectValue(string value)
{
var options = this.GetComponent<Dropdown>().options;
for (int i = 0; i < options.Count; i++)
{
if(options[i].text == value)
{
SelectIndex(i);
return;
}
}
}
}
}
+75 -6
View File
@@ -14,6 +14,8 @@ namespace Assets.Scripts.UI.Control
{
[SerializeField]
private InputField mInnerInputField;
private Outline outline;
private bool isSelected = false;
public string Text
{
@@ -27,28 +29,95 @@ namespace Assets.Scripts.UI.Control
}
}
public void OnSelect(BaseEventData eventData)
{
if (this.gameObject.activeInHierarchy == false)
{
return;
}
isSelected = true;
//throw new NotImplementedException();
this.mInnerInputField.OnSelect(eventData);
var image = this.transform.GetComponent<Image>();
var png = Resources.Load<Sprite>("Images/ipt-1");
image.sprite = png;
//var image = this.transform.GetComponent<Image>();
// var png = Resources.Load<Sprite>("Images/ipt-1");
//image.sprite = png;
outline.enabled = true;
ColorUtility.TryParseHtmlString("#F93086", out Color color);
outline.effectColor = color;
}
public void OnDeselect(BaseEventData eventData)
{
if(this.gameObject.activeInHierarchy == false)
{
return;
}
isSelected = false;
this.mInnerInputField.OnDeselect(eventData);
var image = this.transform.GetComponent<Image>();
var png1 = Resources.Load<Sprite>("Images/ipt-0");
image.sprite = png1;
//var image = this.transform.GetComponent<Image>();
//var png1 = Resources.Load<Sprite>("Images/ipt-0");
//image.sprite = png1;
outline.enabled = false;
}
void Awake()
{
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));
gameObject.GetComponent<Image>().material = material;
outline = this.GetComponent<Outline>();
if (outline == null)
{
outline = this.gameObject.AddComponent<Outline>();
outline.effectDistance = new Vector2(2, 2);
}
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>(this.OnSelect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>(this.OnSelect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>(this.OnDeselect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerEnter, new UnityAction<BaseEventData>((e) =>
{
if (isSelected)
{
return;
}
outline.enabled = true;
ColorUtility.TryParseHtmlString("#6E6E7D", out Color color);
outline.effectColor = color;
}));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(e =>
{
if (isSelected)
{
return;
}
//outline = this.gameObject.AddComponent<Outline>();
outline.enabled = false;
}));
}
public void SetValidate(bool value)
{
if (value)
{
this.mInnerInputField.GetComponent<Text>().color = Color.white;
}
else
{
ColorUtility.TryParseHtmlString("#F93086", out Color color);
this.mInnerInputField.GetComponent<Text>().color = color;
}
}
}
}
@@ -1,15 +0,0 @@
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 PfPrimaryButton : PFUIComponentBase
{
}
}
+229
View File
@@ -0,0 +1,229 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
namespace Assets.Scripts.UI.Control
{
[RequireComponent(typeof(Button))]
public class PFUIButton : PFUIComponentBase
{
public enum Type
{
Normal,
Border,
Primary
}
[SerializeField] Type mType;
private Image image;
private Text text;
private Texture2D cursor;
private Outline outline;
protected void Awake()
{
outline = this.GetComponent<Outline>();
if (mType == Type.Border && outline == null)
{
outline = this.gameObject.AddComponent<Outline>();
outline.effectDistance = new Vector2(2, 2);
}
//设置光标
cursor = Resources.Load<Texture2D>("Images/PointerButtonHover");
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;
InitColor();
BindEvent();
}
private void InitColor()
{
text.color = Color.white;
switch (mType)
{
case Type.Normal:
{
image.color = ConvertColor("#353543");
}
break;
case Type.Border:
{
outline.enabled = true;
image.color = ConvertColor("#3D3E4D");
}
break;
case Type.Primary:
{
image.color = ConvertColor("#F93086");
}
break;
default:
break;
}
}
private void BindEvent()
{
//鼠标进入
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerEnter, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
if (!this.isActiveAndEnabled) return;
Cursor.SetCursor(cursor, Vector2.zero, CursorMode.Auto);
switch (mType)
{
case Type.Normal:
{
image.color = ConvertColor("#5C5C6E");
}
break;
case Type.Border:
{
outline.effectColor = Color.white;
}
break;
case Type.Primary:
{
image.color = ConvertColor("#FF528A");
}
break;
default:
break;
}
}));
//鼠标离开
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
if (!this.isActiveAndEnabled) return;
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
switch (mType)
{
case Type.Normal:
{
image.color = ConvertColor("#353543");
}
break;
case Type.Border:
{
outline.effectColor = ConvertColor("#474759");
}
break;
case Type.Primary:
{
image.color = ConvertColor("#F93086");
}
break;
default:
break;
}
}));
//按下
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerDown, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
if (!this.isActiveAndEnabled) return;
switch (mType)
{
case Type.Normal:
{
image.color = ConvertColor("#23232D");
}
break;
case Type.Border:
{
outline.effectColor = ConvertColor("#353543");
text.color = ConvertColor("#414251");
image.color = ConvertColor("#23232D");
}
break;
case Type.Primary:
{
image.color = ConvertColor("#BD2255");
}
break;
default:
break;
}
}));
//松开
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerUp, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
if (!this.isActiveAndEnabled) return;
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
switch (mType)
{
case Type.Normal:
{
image.color = ConvertColor("#5C5C6E");
}
break;
case Type.Border:
{
outline.effectColor = Color.white;
text.color = Color.white;
}
break;
case Type.Primary:
{
image.color = ConvertColor("#FF528A");
}
break;
default:
break;
}
}));
}
public void SetEnabled(bool value)
{
base.enabled = value;
if (base.enabled)
{
InitColor();
}
else
{
text.color = ConvertColor("#353543");
if (outline != null)
{
outline.enabled = false;
}
image.color = ConvertColor("#414251");
}
}
private Color ConvertColor(string colorStr)
{
ColorUtility.TryParseHtmlString(colorStr, out Color color);
return color;
}
private void OnDestroy()
{
}
}
}
+79
View File
@@ -0,0 +1,79 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class Alert : PFUIPanel
{
private Text text;
private Button button;
protected override void Awake()
{
//var rect = this.gameObject.AddComponent<RectTransform>();
//var layout = this.gameObject.AddComponent<VerticalLayoutGroup>();
//layout.spacing = 20f;
//layout.childAlignment = TextAnchor.MiddleCenter;
var wrap = this.transform.Find("GameObject");
text = wrap.Find("Text").GetComponent<Text>();
//text.transform.SetParent(layout.transform);
//text.text = "阿斯达克法拉盛地方";
///text = layout.transform.GetChild(0).gameObject.AddComponent<Text>();
//text = GetComponentInChildren<Transform>().gameObject.AddComponent<Text>();
button = wrap.Find("Button").GetComponent<Button>();
button.onClick.AddListener(() =>
{
this.Close();
//this.Destroy(true);
//DestroyImmediate(this);
});
}
// Start is called before the first frame update
protected override void Start()
{
}
public void SetText(string txt)
{
if(text == null)
{
return;
}
text.text = txt;
}
// Update is called once per frame
void Update()
{
}
public override void Show()
{
var panel = this.transform.Find("Panel");
var bg = panel.GetComponent<Image>();
//bg.alphaHitTestMinimumThreshold
var color = bg.color;
color.a = 0.6f;
bg.color = color;
base.Show();
}
public override void Close()
{
var panel = this.transform.Find("Panel");
var bg = panel.GetComponent<Image>();
bg.DOFade(0, 0.2f).OnComplete(() =>
{
this.gameObject.SetActive(false);
});
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0ed02cf2a380afd4bae9546154bd13cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -32,9 +32,11 @@ public class ConnectDeviceModal : PFUIPanel
base.Awake();
deviceList = new Dictionary<ushort, DeviceItem>();
var closeBtn = this.transform.Find("CloseBtn");
Logo = this.transform.Find("Logo").GetComponent<Image>();
content = this.transform.Find("Panel").Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
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>();
UIManager.AddEvent(closeBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
@@ -30,17 +30,17 @@ public class QuickLoginUser : MonoBehaviour
//ConfigHelper.CurrentUser = r.data.Value<UserResultModel>("user");
//ConfigHelper.CurrentUser = re;
var usermodel = r.data.Value<JObject>("user");
App.CurrentUser = new UserModel
{
NickName = usermodel.Value<string>("NickName"),
Ftp = usermodel.Value<int>("FTP"),
Weight = usermodel.Value<double>("Weight"),
BicycleWeight = usermodel.Value<double>("BicycleWeight"),
Carlories = "",
Avatar = usermodel.Value<string>("WxHeadImg"),
Distance = 0,
Climb = "",
};
//App.CurrentUser = new UserModel
//{
// NickName = usermodel.Value<string>("NickName"),
// Ftp = usermodel.Value<int>("FTP"),
// Weight = usermodel.Value<double>("Weight"),
// BicycleWeight = usermodel.Value<double>("BicycleWeight"),
// Carlories = "",
// Avatar = usermodel.Value<string>("WxHeadImg"),
// Distance = 0,
// Climb = "",
//};
SceneManager.LoadScene("MainScene");
}
else
@@ -12,7 +12,7 @@ public class MyMap
public int rank { get; set; }
public string image { get; set; }
}
public class MapScript : MonoBehaviour
public class MapItem : MonoBehaviour
{
// Start is called before the first frame update
//[SerializeField] Text text;
@@ -6,12 +6,15 @@ using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class DeviceController : PFUIPanel
{
public Toggle toggle;
private float timer = 1.0f;
private Button mReturnBtn;
private Image antStatus;
private Sprite ant0;
private Sprite ant1;
protected override void Awake()
{
AntConnector.Instance();
@@ -27,24 +30,17 @@ public class DeviceController : PFUIPanel
// UIManager.ShowHomePanel();
//});
this.toggle = this.transform.Find("Toggle").GetComponent<Toggle>();
this.toggle.onValueChanged.AddListener(s =>
{
if (s)
{
this.toggle.transform.GetComponentInChildren<UnityEngine.UI.Text>().color = Color.green;
}
else
{
this.toggle.transform.GetComponentInChildren<UnityEngine.UI.Text>().color = Color.gray;
}
});
mReturnBtn = this.transform.Find("ReturnBtn").GetComponent<Button>();
UIManager.AddEvent(mReturnBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
UIManager.AddEvent(mReturnBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
UIManager.ShowHomePanel();
}));
var bg = this.transform.Find("Status").Find("Bg");
antStatus = bg.Find("Ant+").GetComponent<Image>();
ant0 = Resources.Load<Sprite>("Images/ANT+_0");
ant1 = Resources.Load<Sprite>("Images/ANT+_1");
}
// Update is called once per frame
@@ -53,6 +49,14 @@ public class DeviceController : PFUIPanel
timer -= Time.deltaTime;
if (timer <= 0)
{
if (AntConnector.Instance().IsAvailable)
{
antStatus.sprite = ant1;
}
else
{
antStatus.sprite = ant0;
}
//this.toggle.isOn = AntConnector.Instance().IsAvailable;
//foreach (var item in AntConnector.Instance().discoveredDevices)
@@ -1,14 +1,131 @@
using System.Collections;
using Assets.Scripts;
using Assets.Scripts.Apis;
using Assets.Scripts.Apis.Models;
using Assets.Scripts.UI.Control;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class EditUserController : PFUIPanel
{
private Button mSaveButton;
private PFUIDropdown mSexDropdown;
private PFUIDropdown mDayDropdown;
private PFUIDropdown mMonthDropdown;
private PFUIDropdown mYearDropdown;
private Text mIdText;
private Text mNameText;
private RawImage mHeadImage;
private UserApi userApi;
protected override void Awake()
{
userApi = new UserApi();
mIdText = this.transform.Find("IdText").GetComponent<Text>();
mNameText = this.transform.Find("NameText").GetComponent<Text>();
var panel = this.transform.Find("Panel");
mSexDropdown = panel.Find("SexDropdown").GetComponent<PFUIDropdown>();
mYearDropdown = panel.Find("YearDropdown").GetComponent<PFUIDropdown>();
mMonthDropdown = panel.Find("MonthDropdown").GetComponent<PFUIDropdown>();
mDayDropdown = panel.Find("DayDropdown").GetComponent<PFUIDropdown>();
mSaveButton = this.transform.Find("SaveButton").GetComponent<Button>();
mHeadImage = this.transform.Find("HeadImage").GetComponent<RawImage>();
mSexDropdown.ClearOptions();
mSexDropdown.AddOptions(new List<string>
{
"男","女"
});
mYearDropdown.ClearOptions();
var years = new List<string>();
for (int i = 1960; i < 2099; i++)
{
years.Add(i.ToString());
}
mYearDropdown.AddOptions(years);
mYearDropdown.OnValueChange = (index) =>
{
//Debug.Log(index);
SetDayDropdown();
};
mMonthDropdown.ClearOptions();
var months = new List<string>();
for (int i = 1; i < 13; i++)
{
months.Add(i.ToString());
}
mMonthDropdown.AddOptions(months);
//mMonthDropdown.SelectValue("9");
mMonthDropdown.OnValueChange = (index) =>
{
SetDayDropdown();
};
mDayDropdown.ClearOptions();
SetDayDropdown();
//mDayDropdown.AddOptions()
//mDayDropdown.AddOptions(new List<Dropdown.OptionData>
//{
// new Dropdown.OptionData()
//});
LoadDataSync();
}
async void LoadDataSync()
{
Material material = null;
if (material == null)
{
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
}
var rect = ((RectTransform)mHeadImage.transform).rect;
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;
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);
}
// Start is called before the first frame update
protected override void Start()
{
base.Start();
}
// Update is called once per frame
@@ -16,4 +133,40 @@ public class EditUserController : PFUIPanel
{
}
void SetDayDropdown()
{
mDayDropdown.ClearOptions();
var year = mYearDropdown.SelectedItem;
var month = mMonthDropdown.SelectedItem;
//var date = new DateTime(int.Parse(year), int.Parse(month), 1);
var days = DateTime.DaysInMonth(int.Parse(year), int.Parse(month));
var list = new List<string>();
for (int i = 1; i <= days; i++)
{
list.Add(i.ToString());
}
mDayDropdown.ClearOptions();
mDayDropdown.AddOptions(list);
}
async 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;
//var result = await userApi.Update(user);
//if (result.result == false)
//{
// UIManager.ShowAlert(result.errMsg);
// return;
//}
//App.CurrentUser = user;
UIManager.ShowAlert("result.errMsg");
}
}
@@ -1,4 +1,6 @@
using Assets.Scripts;
using Assets.Scripts.Apis;
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -54,43 +56,65 @@ public class HomeController : PFUIPanel
{
UIManager.ShowUserInfoPanel();
});
if (App.CurrentUser == null)
{
Login();
}
}
private async void Login()
{
var result = await new UserApi().Login("13115011550", "laozhong", "");
App.CurrentUser = result.data;
}
private void GoRide()
{
UIManager.ShowMapListPanel();
//SceneManager.LoadScene("3-MapList");
//DOTween.To()
//this.transform.DOLocalMove(new Vector2(1000, 0), 2.0f).SetEase(Ease.InOutExpo).OnComplete(() =>
//{
//Loom.QueueOnMainThread(() =>
//{
// Debug.Log("ddddddddddddddddddddddddddd");
//});
//});
}
void MoreFunc()
{
Utils.showToast(gameObject, "更多信息", 1);
//Utils.showToast(gameObject, "更多信息", 1);
//DOTween.ToAlpha(() => )
}
void SetCurrentUser()
{
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("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 = 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;
//var user = ConfigHelper.CurrentUser;
//Ftp.text = user.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.Avatar);
}
void GetSummary()
{
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;
//App.CurrentUser.Distance = res.data.TotalDistance;
//App.CurrentUser.Climb = res.data.TotalClimb;
//App.CurrentUser.Carlories = res.data.Kcal;
SetCurrentUser();
//Climb.text = $"{res.data.TotalClimb.ToString()}M";
//Calories.text = $"{res.data.Kcal.ToString()}KCAL";
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapController : MonoBehaviour
{
// 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: 969b87ed3066bec4a9981a69d7dfb8e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -7,7 +7,7 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MapDetailController : MonoBehaviour
public class MapDetailController : PFUIPanel
{
// Start is called before the first frame update
[HideInInspector] public int id = 0;
@@ -38,7 +38,7 @@ public class MapDetailController : MonoBehaviour
{
transform.Find("BtnReturn").GetComponent<Button>().onClick.AddListener(() =>
{
UIManager.ShowHomePanel();
UIManager.ShowMapListPanel();
});
}
}
@@ -11,7 +11,7 @@ using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MapListController : MonoBehaviour
public class MapListController : PFUIPanel
{
// Start is called before the first frame update
[SerializeField] GameObject map;
@@ -20,6 +20,8 @@ public class MapListController : MonoBehaviour
[HideInInspector] public int pageIndex = 0;
[HideInInspector] public int pageSize = 20;
[HideInInspector] public string hard = "全部";
private Button returnBtn;
public GameObject Content {
get
{
@@ -27,7 +29,7 @@ public class MapListController : MonoBehaviour
}
}
private bool isEnd = false;
void Start()
protected override void Start()
{
//if (hardSelector != null)
//{
@@ -51,6 +53,16 @@ public class MapListController : MonoBehaviour
//UIManager.AddEvent(transform.Find("Panel").Find("Panel"))
//var obj = Instantiate(Resources.Load<GameObject>("Canvas"));
//obj.transform.parent = transform.parent;
var btnQuit = this.transform.Find("BtnQuit");
if(btnQuit != null)
{
returnBtn = btnQuit.GetComponent<Button>();
UIManager.AddEvent(returnBtn.gameObject, EventTriggerType.PointerClick, (e) =>
{
UIManager.ShowHomePanel();
});
}
}
private void OnEndDrag(BaseEventData arg0)
@@ -103,7 +115,7 @@ public class MapListController : MonoBehaviour
foreach (var item in list)
{
var obj = Instantiate(map);
obj.GetComponent<MapScript>().Initial(item);
obj.GetComponent<MapItem>().Initial(item);
//obj.SendMessage("Initial", );
obj.transform.parent = content.transform;
obj.transform.localScale = new Vector3(1, 1, 1);
+16 -1
View File
@@ -17,9 +17,24 @@ public class PFUIPanel : UIBehaviour
Application.OpenURL(url);
}
public virtual void Show()
{
base.gameObject.SetActive(true);
}
public virtual void Close()
{
DestroyImmediate(this.gameObject);
//DestroyImmediate(this.gameObject);
this.gameObject.SetActive(false);
}
public void AddChild(PFUIPanel child)
{
if(child == null)
{
return;
}
child.transform.SetParent(this.transform);
}
}
//}