登录页一些特效,路书列表详情框架

This commit is contained in:
Caiyanpeng committed 2021-04-01 11:01:05 +08:00
1 parent 326b74bd03
commit 996f924719
50 files changed
+19916 -6804

No files matched your search

+110 -9
View File
@@ -8,27 +8,53 @@ using System.Collections.Generic;
using System.Reflection;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
//记录:小f 是-457和-681
public class LoginForm
{
public InputField phone;
public InputField pwd;
}
public class LoginController : MonoBehaviour
{
[SerializeField] InputField phone;
[SerializeField] InputField pwd;
[SerializeField] InputField[] loginForm;
[SerializeField] Button login;
[SerializeField] Button loginNewAccount;
[SerializeField] Button loginReturn2;
[SerializeField] Button returnQuick;
[SerializeField] Button regNext;
[SerializeField] Button regPrev;
[SerializeField] Button sign;
[SerializeField] Button remember;
[SerializeField] GameObject loginScrollView;
[SerializeField] GameObject signScrollView;
[SerializeField] GameObject avatarScrollView;
[SerializeField] RawImage loading;
[SerializeField] Button exit;
private ScrollRect scrollPanel;
private ScrollRect scrollSign;
private ScrollRect scrollAvatar;
private Transform imagexf;
// Start is called before the first frame update
void Start()
{
//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);
@@ -46,6 +72,10 @@ public class LoginController : MonoBehaviour
{
scrollSign = signScrollView.GetComponent<ScrollRect>();
}
if (avatarScrollView != null)
{
scrollAvatar = avatarScrollView.GetComponent<ScrollRect>();
}
if (loginNewAccount != null)
{
loginNewAccount.onClick.AddListener(goLogin);
@@ -58,13 +88,76 @@ public class LoginController : MonoBehaviour
{
sign.onClick.AddListener(goSign);
}
if (loginReturn2 != null)
{
loginReturn2.onClick.AddListener(goLoginReturn2);
}
if (regNext != null)
{
regNext.onClick.AddListener(goRegNext);
}
if (regPrev != null)
{
regPrev.onClick.AddListener(goRegPrev);
}
if (exit != null)
{
exit.onClick.AddListener(() => Application.Quit());
}
if (remember != null)
{
remember.onClick.AddListener(() =>
{
var gou = remember.transform.Find("Gou");
if (gou.gameObject.activeSelf)
{
gou.gameObject.SetActive(false);
}
else
{
gou.gameObject.SetActive(true);
}
});
}
imagexf = transform.Find("Panel").Find("LoginContainer").Find("Imagexf");
}
private void OnLoginInputDeSelect(BaseEventData arg0, GameObject game)
{
var image = game.transform.GetComponent<Image>();
image.sprite = Resources.Load<Sprite>("Images/gl-no");
//var rect = game.transform.GetComponent<RectTransform>();
//rect.SetSiblingIndex(rect.childCount-1);
}
private void OnLoginInputSelect(BaseEventData arg0,GameObject game)
{
var image = game.transform.GetComponent<Image>();
image.sprite = Resources.Load<Sprite>("Images/gl");
//var rect = game.transform.GetComponent<RectTransform>();
//rect.SetSiblingIndex(0);
}
private void goRegPrev()
{
StartScrollSign(0);
}
private void goRegNext()
{
StartScrollSign(1);
}
private void goLoginReturn2()
{
this.StartScrollPanel(1);
}
void ReturnQuick()
{
if (imagexf != null)
{
imagexf.DOLocalMove(new Vector3(0, -457, 0), 0.3f);
imagexf.DOLocalMove(new Vector3(0, -447, 0), 0.3f);
}
this.StartScrollPanel(0);
}
@@ -72,17 +165,18 @@ public class LoginController : MonoBehaviour
{
if (imagexf != null)
{
imagexf.DOLocalMove(new Vector3(0, -681, 0), 0.3f);
imagexf.DOLocalMove(new Vector3(0, -635, 0), 0.3f);
}
this.StartScrollPanel(1);
}
void goSign()
{
this.StartScrollPanel(2);
this.StartScrollSign(0);
}
async void Submit()
{
if (phone == null || pwd == null)
if (loginForm[0] == null || loginForm[1] == null)
{
Utils.showToast(gameObject, "未绑定", 1);
return;
@@ -109,10 +203,10 @@ public class LoginController : MonoBehaviour
// Update is called once per frame
void Update()
{
Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
if (phone.isFocused && pwd != null && Input.GetKeyDown(KeyCode.Tab))
//Debug.Log($"{phone.isFocused}, ${pwd != null}, ${Input.GetKeyDown(KeyCode.Tab)}");
if (loginForm[0].isFocused && loginForm[1] != null && Input.GetKeyDown(KeyCode.Tab))
{
pwd.ActivateInputField();
loginForm[1].ActivateInputField();
}
goScrollPanel();
goScrollSign();
@@ -131,7 +225,7 @@ public class LoginController : MonoBehaviour
#region 主页面滑动逻辑
private int tmpImdex = 0;
private int scrollPanelIndex = 2;
private float scrollValue = 0.5f;
//private float scrollValue = 0.5f;
private bool startScrollPanel = false;
private void StartScrollPanel(int index)
{
@@ -142,6 +236,7 @@ public class LoginController : MonoBehaviour
private void goScrollPanel()
{
var index = scrollPanelIndex;
var scrollValue = 1f/(3 - 1);
var value = index * scrollValue;
if (scrollPanel != null && startScrollPanel)
{
@@ -183,6 +278,12 @@ public class LoginController : MonoBehaviour
#region 注册页面滑动逻辑
private bool startScrollSign = false;
private int scrollSignIndex = 0;
private void StartScrollSign(int index)
{
if (startScrollSign) return;
scrollSignIndex = index;
startScrollSign = true;
}
private void goScrollSign()
{
float value = scrollSignIndex;
+2 -2
View File
@@ -45,13 +45,13 @@ namespace Assets.Scripts.UI.Control
public void OnSelect(BaseEventData eventData)
{
var image = this.transform.GetComponent<Image>();
var png = Resources.Load<Sprite>("Images/input-bg2");
var png = Resources.Load<Sprite>("Images/ipt-1");
image.sprite = png;
}
public void OnDeselect(BaseEventData eventData)
{
var image = this.transform.GetComponent<Image>();
var png1 = Resources.Load<Sprite>("Images/input-bg1");
var png1 = Resources.Load<Sprite>("Images/ipt-0");
image.sprite = png1;
}
+2 -2
View File
@@ -32,7 +32,7 @@ namespace Assets.Scripts.UI.Control
//throw new NotImplementedException();
this.mInnerInputField.OnSelect(eventData);
var image = this.transform.GetComponent<Image>();
var png = Resources.Load<Sprite>("Images/input-bg2");
var png = Resources.Load<Sprite>("Images/ipt-1");
image.sprite = png;
}
@@ -40,7 +40,7 @@ namespace Assets.Scripts.UI.Control
{
this.mInnerInputField.OnDeselect(eventData);
var image = this.transform.GetComponent<Image>();
var png1 = Resources.Load<Sprite>("Images/input-bg1");
var png1 = Resources.Load<Sprite>("Images/ipt-0");
image.sprite = png1;
}
@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DropdownScript : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] string label;
void Start()
{
gameObject.transform.Find("Label").GetComponent<Text>().text = label;
}
// Update is called once per frame
void Update()
{
}
}
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5b590b8b6670b334ea1953fea1deba17
guid: ae819c44673b2e648813f6f57f39b4b6
MonoImporter:
externalObjects: {}
serializedVersion: 2
-8
View File
@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: d0341abab3ca8db49b556a2b5cb0465b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,21 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class MapListScript : MonoBehaviour, IEndDragHandler
{
public void OnEndDrag(PointerEventData eventData)
{
var sc = gameObject.transform.parent.GetComponent<MapListController>();
if (eventData.position.y < 0)
{
sc.Refresh();
}
if (eventData.position.y + Screen.height > sc.Content.GetComponent<RectTransform>().rect.height)
{
sc.pageIndex++;
sc.GetList();
}
}
}
+10 -15
View File
@@ -15,9 +15,9 @@ public class MyMap
public class MapScript : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] Text text;
[SerializeField] GameObject panel;
[SerializeField] RawImage rawImage;
//[SerializeField] Text text;
//[SerializeField] GameObject panel;
//[SerializeField] RawImage rawImage;
void Start()
{
}
@@ -31,19 +31,14 @@ public class MapScript : MonoBehaviour
{
gameObject.GetComponent<Button>().onClick.AddListener(()=>
{
UIManager.ShowMapDetailPanel(myMap.Id);
//SceneManager.LoadScene("4-Demo", LoadSceneMode.Additive);
});
text.text = myMap.Name;
Utils.DisplayImage(StartCoroutine, rawImage, myMap.CoverImage);
int i = 0;
foreach (RectTransform transform in panel.transform)
{
//if (i < myMap.rank && i < 5)
if (i < 3 && i<5)
{
transform.GetComponent<Image>().color = new Color(255, 255, 0);
i++;
}
}
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
Utils.DisplayImage(StartCoroutine, transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage);
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")}%";
}
}
@@ -0,0 +1,55 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MapDetailController : MonoBehaviour
{
// Start is called before the first frame update
[HideInInspector] public int id = 0;
[HideInInspector] public MapRoute map;
void Start()
{
if (id != 0)
{
var r = ConfigHelper.mapApi.GetById(id);
if (r.result)
{
map = r.data;
}
else
{
Utils.showToast(gameObject, r.errMsg, 1);
}
}
if (transform.Find("BtnGoRide") != null)
{
transform.Find("BtnGoRide").GetComponent<Button>().onClick.AddListener(GoRide);
}
if (transform.Find("Name") != null)
{
transform.Find("Name").GetComponent<Text>().text = map.Name;
}
if (transform.Find("BtnReturn") != null)
{
transform.Find("BtnReturn").GetComponent<Button>().onClick.AddListener(() =>
{
UIManager.ShowHomePanel();
});
}
}
private void GoRide()
{
Utils.showToast(gameObject, "去骑行", 1);
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 858ac526aed2cf641a3c0f50a8c7730d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,11 +1,13 @@
using Assets.Cyp.Common;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
@@ -14,7 +16,7 @@ public class MapListController : MonoBehaviour
// Start is called before the first frame update
[SerializeField] GameObject map;
[SerializeField] GameObject content;
[SerializeField] Dropdown hardSelector;
[SerializeField] GameObject scroll;
[HideInInspector] public int pageIndex = 0;
[HideInInspector] public int pageSize = 20;
[HideInInspector] public string hard = "全部";
@@ -27,33 +29,53 @@ public class MapListController : MonoBehaviour
private bool isEnd = false;
void Start()
{
if (hardSelector != null)
{
hardSelector.onValueChanged.AddListener(ChangeHard);
}
//if (hardSelector != null)
//{
// hardSelector.onValueChanged.AddListener(ChangeHard);
//}
if (content!=null)
{
var transform = content.transform.GetComponent<RectTransform>();
var layout = content.GetComponent<GridLayoutGroup>();
if (layout != null)
{
var width = transform.rect.width;
layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
}
//var transform = content.transform.GetComponent<RectTransform>();
//var layout = content.GetComponent<GridLayoutGroup>();
//if (layout != null)
//{
// var width = transform.rect.width;
// layout.cellSize = new Vector2((width - 120) / 5, (width - 120) / 5);
//}
}
GetList();
if (scroll != null)
{
UIManager.AddEvent(scroll, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
}
//UIManager.AddEvent(transform.Find("Panel").Find("Panel"))
//var obj = Instantiate(Resources.Load<GameObject>("Canvas"));
//obj.transform.parent = transform.parent;
}
private void ChangeHard(int index)
private void OnEndDrag(BaseEventData arg0)
{
var text = hardSelector.options[index].text;
if (text == "全部难度")
var scrollrect = scroll.GetComponent<ScrollRect>();
if (scrollrect.verticalNormalizedPosition <= 0)
{
Debug.Log(scrollrect.verticalNormalizedPosition);
pageIndex++;
GetList();
}
if (scrollrect.verticalNormalizedPosition >= 1)
{
Refresh();
}
}
private void ChangeHard(int index)
{
//var text = hardSelector.options[index].text;
//if (text == "全部难度")
//{
//}
}
public void GetList()
+16
View File
@@ -55,6 +55,15 @@ public class UIManager : MonoBehaviour
}
}
private MapDetailController mMapDetailController;
public MapDetailController MapDetailPanel
{
get
{
return this.GetPanelInstance("MapDetailPanel", ref this.mMapDetailController);
}
}
private EditUserController mEditUserController;
public EditUserController EditUserPanel
{
@@ -181,6 +190,13 @@ public class UIManager : MonoBehaviour
{
UIManager.Show(UIManager.Instance.MapListPanel, UIManager.Instance.MainPanel);
}
public static void ShowMapDetailPanel(int id)
{
var ctrl = UIManager.Instance.MapDetailPanel;
ctrl.id = id;
UIManager.Show(UIManager.Instance.MapDetailPanel, UIManager.Instance.MainPanel);
}
public static void AddEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction<BaseEventData> call)
{
EventTrigger et = gameObject.GetComponent<EventTrigger>();