浏览器嵌入,国旗文件

This commit is contained in:
Caiyanpeng committed 2021-04-09 09:19:04 +08:00
1 parent e7a3214cb5
commit 07feba912c
552 files changed
+39279 -8128

No files matched your search

+7 -3
View File
@@ -1,4 +1,5 @@
using System.Collections;
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
@@ -7,14 +8,17 @@ public class ButtonHoverScript : MonoBehaviour, IPointerExitHandler, IPointerEnt
{
public void OnPointerEnter(PointerEventData eventData)
{
//transform.DOMove
Debug.Log("鼠标悬浮");
gameObject.transform.localScale = new Vector3(1.01f, 1.01f, 1f);
//gameObject.transform.localScale = new Vector3(1.01f, 1.01f, 1f);
transform.DOScale(new Vector3(1.01f, 1.01f, 1f),0.2f);
}
public void OnPointerExit(PointerEventData eventData)
{
Debug.Log("鼠标松开");
gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
transform.DOScale(new Vector3(1f, 1f, 1f), 0.2f);
//gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
}
// Start is called before the first frame update
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eec3152daffe9ff4895d210abfb2ebc5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,97 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Assets.Scripts.UI.Prefab.Login
{
public static class DayOptions
{
private static List<Dropdown.OptionData> SetOptions(int day)
{
var op = new Dropdown.OptionDataList();
for (int m = 1; m <= day; m++)
{
op.options.Add(new Dropdown.OptionData(m.ToString()));
}
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 class CountryModel
{
public string country { get;set; }
public string abbreviation { get; set; }
public string source { get; set; }
}
public class LoginRegOptions
{
public List<Dropdown.OptionData> years;
public List<Dropdown.OptionData> months;
public List<Dropdown.OptionData> days;
public List<Dropdown.OptionData> genders;
public List<Dropdown.OptionData> countrys;
public List<Dropdown.OptionData> units;
public int countryDefaultValue;
private List<CountryModel> countryList;
public LoginRegOptions()
{
years = new List<Dropdown.OptionData>();
for (int y = 1970; y <= 2021; y++)
{
years.Add(new Dropdown.OptionData(y.ToString()));
}
months = new List<Dropdown.OptionData>();
for (int m = 1; m <= 12; m++)
{
months.Add(new Dropdown.OptionData(m.ToString()));
}
days = new List<Dropdown.OptionData>();
genders = new List<Dropdown.OptionData>() {new Dropdown.OptionData("Male"), new Dropdown.OptionData("FeMale") };
var countryJson = Resources.Load<TextAsset>("UI/flags-mini").text;
countryList = JsonConvert.DeserializeObject<List<CountryModel>>(countryJson);
countrys = countryList.Select(x => new Dropdown.OptionData(x.country)).ToList();
countryDefaultValue = countryList.FindIndex(x => x.country == "中国");
units = new List<Dropdown.OptionData>() { new Dropdown.OptionData("Metric"), new Dropdown.OptionData("Imperial") };
}
public Texture GetCountryImage(int index)
{
var c = countryList[index];
if (c == null) return null;
return Resources.Load<Texture>(c.source);
}
public int GetCountryIndexByCode(string code)
{
var c = countryList.FindIndex(x => x.abbreviation.ToLower() == code.ToLower());
if (c == -1) return countryDefaultValue;
return c;
}
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;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ca65c2211952c474ebd054dbec009223
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,101 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;
public class QuickLoginScroll : MonoBehaviour
{
// Start is called before the first frame update
private ScrollRect scroll;
private Transform content;
private float contentSize;
private int count;
[SerializeField] Button L, R;
void Start()
{
scroll = gameObject.GetComponent<ScrollRect>();
content = gameObject.transform.Find("Viewport").Find("Content");
//Initial();
if (L != null)
{
L.onClick.AddListener(goLeft);
}
if (R != null)
{
R.onClick.AddListener(goRight);
}
}
public void Initial()
{
count = content.childCount;
if (content.childCount - 2 > 0)
{
contentSize = 1f / (content.childCount - 2);
}
else
{
contentSize = 0;
}
//scroll.horizontalNormalizedPosition = 0;
Canvas.ForceUpdateCanvases();
scroll.horizontalNormalizedPosition = contentSize/2;
SetColor();
}
void goLeft()
{
if (scroll.horizontalNormalizedPosition <= contentSize) return;
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = -1 * contentSize / 30;
}
void goRight()
{
if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
if (!start) startPosition = scroll.horizontalNormalizedPosition;
start = true;
scrollValue = contentSize / 30;
}
private bool start = false, _lock = false;
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
void SetColor()
{
int index = (int)System.Math.Round(
(scroll.horizontalNormalizedPosition + (contentSize / 2)) / contentSize,
0);
for (int i = 1; i < content.childCount-1; i++)
{
string c;
if (i == index)
{
content.GetChild(i).GetComponent<QuickLoginUser>().setActive();
}
else
{
content.GetChild(i).GetComponent<QuickLoginUser>().setNoActive();
}
}
}
// Update is called once per frame
void Update()
{
if (start)
{
totalScrollValue += scrollValue;
if (System.Math.Abs(totalScrollValue) >= contentSize)
{
scrollValue = 0;
start = false;
scroll.horizontalNormalizedPosition = startPosition + totalScrollValue;
//Debug.Log();
SetColor();
totalScrollValue = 0;
}
else
{
scroll.horizontalNormalizedPosition += scrollValue;
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a77e784c857a15f4593d004821ce2757
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,106 @@
using Assets.Scripts;
using Assets.Scripts.Apis;
using Assets.Scripts.Apis.Models;
using DG.Tweening;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class QuickLoginUser : MonoBehaviour
{
QUserInfo user;
// Start is called before the first frame update
void Start()
{
}
public void Initial(QUserInfo user)
{
if (user ==null) return;
transform.GetComponent<Button>().onClick.AddListener(() =>
{
ApiBase.SetCookie(user.Cookie);
var r = ConfigHelper.userApi.GetUserInfo();
if (r.result)
{
//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 = "",
};
SceneManager.LoadScene("MainScene");
}
else
{
Utils.showToast(gameObject, r.errMsg);
}
});
this.user = user;
Utils.DisplayImage(StartCoroutine, transform.Find("Avatar").GetComponent<RawImage>(),user.Avatar);
transform.Find("NickNameText").GetComponent<Text>().text = user.NickName;
transform.Find("BtnDelete").GetComponent<Button>().onClick.AddListener(DestroySelf);
}
// Update is called once per frame
void Update()
{
}
private void OnDestroy()
{
}
void DestroySelf()
{
var content = transform.parent;
var index = transform.GetSiblingIndex() - 1;
DestroyImmediate(gameObject);
//if (content.childCount == 2)
//{
// var info = Instantiate(Resources.Load<GameObject>("UI/Prefab/Login/QuickUserInfo")).transform;
// info.GetComponent<QuickLoginUser>().Initial(null);
// info.parent = content;
// info.localScale = new Vector3(1, 1, 1);
// content.Find("empty1").transform.SetSiblingIndex(0);
// content.Find("empty2").transform.SetSiblingIndex(content.childCount - 1);
//}
content.parent.parent.GetComponent<QuickLoginScroll>().Initial();
DeleteList(index);
}
private void DeleteList(int index)
{
var userInfosJson = PlayerPrefs.GetString("UserInfos");
var userInfos = JsonConvert.DeserializeObject<List<QUserInfo>>(userInfosJson);
userInfos.RemoveAt(index);
PlayerPrefs.SetString("UserInfos", JsonConvert.SerializeObject(userInfos));
}
public void setActive()
{
//ColorUtility.TryParseHtmlString("#ffffffff", out Color color);
//transform.Find("Avatar").GetComponent<RawImage>().color = color;
transform.Find("Avatar").GetComponent<RawImage>().DOFade(1f, 0.3f);
transform.GetComponent<Button>().enabled = true;
transform.Find("NickNameText").GetComponent<Text>().enabled = true;
}
public void setNoActive()
{
//ColorUtility.TryParseHtmlString("#ffffff80", out Color color);
//transform.Find("Avatar").GetComponent<RawImage>().color = color;
transform.Find("Avatar").GetComponent<RawImage>().DOFade(0.5f, 0.3f);
transform.GetComponent<Button>().enabled = false;
transform.Find("NickNameText").GetComponent<Text>().enabled = false;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 26e36fe24c739ed4eb5fc882dc2a1340
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,89 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
[RequireComponent(typeof(ScrollRect))]
public class ScrollRectAutoScroll : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public float scrollSpeed = 10f;
private bool mouseOver = false;
private List<Selectable> m_Selectables = new List<Selectable>();
private ScrollRect m_ScrollRect;
private Vector2 m_NextScrollPosition = Vector2.up;
void OnEnable()
{
if (m_ScrollRect)
{
m_ScrollRect.content.GetComponentsInChildren(m_Selectables);
}
}
void Awake()
{
m_ScrollRect = GetComponent<ScrollRect>();
}
void Start()
{
if (m_ScrollRect)
{
m_ScrollRect.content.GetComponentsInChildren(m_Selectables);
}
ScrollToSelected(true);
}
void Update()
{
// Scroll via input.
InputScroll();
if (!mouseOver)
{
// Lerp scrolling code.
m_ScrollRect.normalizedPosition = Vector2.Lerp(m_ScrollRect.normalizedPosition, m_NextScrollPosition, scrollSpeed * Time.deltaTime);
}
else
{
m_NextScrollPosition = m_ScrollRect.normalizedPosition;
}
}
void InputScroll()
{
if (m_Selectables.Count > 0)
{
if (Input.GetButtonDown("Horizontal") || Input.GetButtonDown("Vertical") || Input.GetButton("Horizontal") || Input.GetButton("Vertical"))
{
ScrollToSelected(false);
}
}
}
void ScrollToSelected(bool quickScroll)
{
int selectedIndex = -1;
Selectable selectedElement = EventSystem.current.currentSelectedGameObject ? EventSystem.current.currentSelectedGameObject.GetComponent<Selectable>() : null;
if (selectedElement)
{
selectedIndex = m_Selectables.IndexOf(selectedElement);
}
if (selectedIndex > -1)
{
if (quickScroll)
{
m_ScrollRect.normalizedPosition = new Vector2(0, 1 - (selectedIndex / ((float)m_Selectables.Count - 1)));
m_NextScrollPosition = m_ScrollRect.normalizedPosition;
}
else
{
m_NextScrollPosition = new Vector2(0, 1 - (selectedIndex / ((float)m_Selectables.Count - 1)));
}
}
}
public void OnPointerEnter(PointerEventData eventData)
{
mouseOver = true;
}
public void OnPointerExit(PointerEventData eventData)
{
mouseOver = false;
ScrollToSelected(false);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6af95c5bd558984fb9ce789f2f13d0c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -10,17 +10,17 @@ using UnityEngine.UI;
public class HomeController : PFUIPanel
{
[SerializeField] Text Ftp;
[SerializeField] RawImage Avatar;
[SerializeField] Text Weight;
[SerializeField] Text WKG;
[SerializeField] Text Calories;
[SerializeField] Text KM;
[SerializeField] Text Climb;
[SerializeField] Text NickName;
[SerializeField] Button More;
//[SerializeField] Text Ftp;
//[SerializeField] RawImage Avatar;
//[SerializeField] Text Weight;
//[SerializeField] Text WKG;
//[SerializeField] Text Calories;
//[SerializeField] Text KM;
//[SerializeField] Text Climb;
//[SerializeField] Text NickName;
//[SerializeField] Button More;
[SerializeField] Button BtnRide;
[SerializeField] Transform userInfo;
// Start is called before the first frame update
protected override void Start()
{
@@ -33,11 +33,10 @@ public class HomeController : PFUIPanel
// toast.GetComponent<RectTransform>().position = new Vector3(Screen.width / 2, Screen.height / 2, 0);
// toast.transform.parent = parent;
//}
//if (ConfigHelper.CurrentUser != null)
//{
// SetCurrentUser();
// GetSummary();
//}
if (App.CurrentUser != null)
{
GetSummary();
}
//if (More != null)
//{
// More.onClick.AddListener(MoreFunc);
@@ -50,7 +49,7 @@ public class HomeController : PFUIPanel
UIManager.ShowDevicePanel();
});
var avatar = this.transform.Find("UserInfo").Find("Image");
var avatar = userInfo.Find("Avatar");
UIManager.AddEvent(avatar.gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowUserInfoPanel();
@@ -70,21 +69,31 @@ public class HomeController : PFUIPanel
void SetCurrentUser()
{
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, Avatar, user.WxHeadImg);
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;
//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);
}
void GetSummary()
{
var res = ConfigHelper.userApi.GetSummary();
if (res.result)
{
KM.text = $"{res.data.TotalDistance.ToString("#0.00")}KM";
Climb.text = $"{res.data.TotalClimb.ToString()}M";
Calories.text = $"{res.data.Kcal.ToString()}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";
//Calories.text = res.data.
}
else