完成大地图主要界面

This commit is contained in:
suntao committed 2021-04-15 09:01:07 +08:00
1 parent 5156473bb2
commit d22eecd133
78 files changed
+8684 -6941

No files matched your search

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraRectAutoFit : MonoBehaviour
{
float targetaspect = 16.0f / 9.0f;
// Start is called before the first frame update
void Start()
{
// determine the game window's current aspect ratio
float windowaspect = (float)Screen.width / (float)Screen.height;
// current viewport height should be scaled by this amount
float scaleheight = windowaspect / targetaspect;
// obtain camera component so we can modify its viewport
Camera camera = Camera.main;
// if scaled height is less than current height, add letterbox
if (scaleheight <= 1.0f)
{
Rect rect = camera.rect;
rect.width = 1.0f;
rect.height = scaleheight;
rect.x = 0;
rect.y = (1.0f - scaleheight) / 2.0f;
camera.rect = rect;
}
else // add pillarbox
{
float scalewidth = 1.0f / scaleheight;
Rect rect = camera.rect;
rect.width = scalewidth;
rect.height = 1.0f;
rect.x = (1.0f - scalewidth) / 2.0f;
rect.y = 0;
camera.rect = rect;
}
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3083a61e316cc854fb0fa28e7fd7e237
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+117
View File
@@ -0,0 +1,117 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Assets.Scripts.UI.UIEffect;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class Item : MonoBehaviour, IPointerClickHandler
{
private Text text;
private string Text
{
get
{
return text.text;
}
set
{
text.text = value;
}
}
private Text km;
private string Distance
{
get
{
return km.text;
}
set
{
km.text = value;
}
}
private Text count;
private string Count
{
get
{
return count.text;
}
set
{
count.text = value;
}
}
public Action onClick;
private void Awake()
{
text = this.transform.Find("name").GetComponent<Text>();
km = this.transform.Find("km").GetComponent<Text>();
count = this.transform.Find("count").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));
this.GetComponent<Image>().material = material;
}
public void Selected(bool value)
{
if (value)
{
this.GetComponent<UIGradient>().enabled = true;
this.GetComponent<UIGradient>().color1 = Utils.HexToColor("FF7485");
this.GetComponent<UIGradient>().color2 = Utils.HexToColor("F93086");
this.GetComponent<Image>().color = Color.white;
this.transform.Find("km").GetComponent<Text>().color = Color.white;
this.transform.Find("count").GetComponent<Text>().color = Color.white;
}
else
{
this.GetComponent<UIGradient>().enabled = false;
this.GetComponent<Image>().color = Utils.HexToColor("353543");
this.transform.Find("km").GetComponent<Text>().color = Utils.HexToColor("5C5C6E");
this.transform.Find("count").GetComponent<Text>().color = Utils.HexToColor("F93086");
}
}
public void SetModel(NearRouteModel model)
{
this.Text = model.Name;
this.Distance = model.Distance + "KM";
this.Count = model.TheHeat.ToString();
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnPointerClick(PointerEventData eventData)
{
if(onClick != null)
{
onClick();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4798070a21cb55b40a0a89ac2b84f135
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+111
View File
@@ -0,0 +1,111 @@
using Assets.Scripts.Apis.Models;
using Assets.Scripts.UI.Control;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Tips : MonoBehaviour
{
public NearRouteModel Model
{
get
{
return _model;
}
}
private Text Name;
private Text Count;
private Text Distance;
private Text TotalClimb;
private PFUIButton pFUIButton;
private void Awake()
{
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
var rect = ((RectTransform)transform).rect;
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, 40f, 0));
this.GetComponent<Image>().material = material;
Name = this.transform.Find("Name").GetComponent<Text>();
Count = this.transform.Find("Count").GetComponent<Text>();
Distance = this.transform.Find("Distance").GetComponent<Text>();
TotalClimb = this.transform.Find("TotalClimb").GetComponent<Text>();
pFUIButton = this.transform.Find("Ride").GetComponent<PFUIButton>();
UIManager.AddEvent(pFUIButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (e) => {
App.RouteIdParam = _model.Id;
SceneManager.LoadScene("Ride");
});
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
NearRouteModel _model;
public void SetModel(NearRouteModel model)
{
if (this.isActiveAndEnabled)
{
if(_model.Id == model.Id)
{
//this.gameObject.SetActive(false);
return;
}
}
else
{
//this.gameObject.SetActive(true);
_model = model;
Name.text = _model.Name;
Count.text = _model.TheHeat.ToString();
Distance.text = _model.Distance.ToString("#.0")+"KM";
TotalClimb.text = _model.TotalClimb.ToString();
}
}
public void Show(Vector3 position, NearRouteModel model)
{
//if(position.y > position.z)
//{
// position.y = position.z;
//}
this.transform.position = position;
var localPosition = this.transform.localPosition;
if (localPosition.y + 150 > localPosition.z)
{
localPosition.y = localPosition.z -150;
}
if(localPosition.x * -1f > localPosition.z)
{
localPosition.x = localPosition.z * -1f;
}
else if(localPosition.x > localPosition.z *2)
{
localPosition.x = localPosition.z * 2;
}
this.transform.localPosition = localPosition;
this.transform.localScale = new Vector2(2, 2);
this.SetModel(model);
//tips.Show();
this.gameObject.SetActive(true);
}
public void Hide()
{
this.gameObject.SetActive(false);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1614be1af0822445936f92435d0162b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: