Merge branch 'dev_cyp' into dev_ar_cyp
# Conflicts: # Assets/Resources/UI/Font/HanWangZonYi.ttf.meta # Assets/Resources/UI/language.json # Assets/Scenes/Login.unity # Assets/Scripts/Apis/Models/MapRoute.cs # Assets/Scripts/App.cs # Assets/Scripts/ConfigHelper.cs # Assets/Scripts/Scenes/Ride/Scripts/PlayerController.cs # Assets/Scripts/UIManager.cs # Assets/Scripts/Utils/Utils.cs
This commit is contained in:
commit
e513eeac5c
301 files changed
+49814
-11770
No files matched your search
@@ -30,13 +30,17 @@ namespace Assets.Scripts.UI.Control
|
||||
}
|
||||
|
||||
string placeHolderText;
|
||||
public Action CustomSelect = null, CustomDeSelect = null,CustomEnter = null;
|
||||
public void OnSelect(BaseEventData eventData)
|
||||
{
|
||||
if (this.gameObject.activeInHierarchy == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CustomSelect != null)
|
||||
{
|
||||
CustomSelect.Invoke();
|
||||
}
|
||||
isSelected = true;
|
||||
//throw new NotImplementedException();
|
||||
this.mInnerInputField.OnSelect(eventData);
|
||||
@@ -63,7 +67,10 @@ namespace Assets.Scripts.UI.Control
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CustomDeSelect != null)
|
||||
{
|
||||
CustomDeSelect.Invoke();
|
||||
}
|
||||
isSelected = false;
|
||||
this.mInnerInputField.OnDeselect(eventData);
|
||||
transform.Find("Placeholder").GetComponent<Text>().text = App.GetLocalString(placeHolderText);
|
||||
@@ -72,7 +79,33 @@ namespace Assets.Scripts.UI.Control
|
||||
//image.sprite = png1;
|
||||
outline.enabled = false;
|
||||
}
|
||||
|
||||
void OnEnter(BaseEventData eventData)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (CustomEnter != null)
|
||||
{
|
||||
CustomEnter.Invoke();
|
||||
}
|
||||
outline.enabled = true;
|
||||
ColorUtility.TryParseHtmlString("#6E6E7D", out Color color);
|
||||
outline.effectColor = color;
|
||||
}
|
||||
private void OnExit(BaseEventData eventData)
|
||||
{
|
||||
if (isSelected)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (CustomDeSelect != null)
|
||||
{
|
||||
CustomDeSelect.Invoke();
|
||||
}
|
||||
//outline = this.gameObject.AddComponent<Outline>();
|
||||
outline.enabled = false;
|
||||
}
|
||||
void Awake()
|
||||
{
|
||||
Material material = null;
|
||||
@@ -95,26 +128,8 @@ namespace Assets.Scripts.UI.Control
|
||||
//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;
|
||||
}));
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerEnter, new UnityAction<BaseEventData>(this.OnEnter));
|
||||
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(OnExit));
|
||||
placeHolderText = transform.Find("Placeholder").GetComponent<Text>().text;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,89 @@
|
||||
using System.Collections;
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class PFUISlider : MonoBehaviour
|
||||
{
|
||||
private Text text;
|
||||
private Slider slider;
|
||||
public System.Func<float, float> valueHandler = (a) => a * 100;
|
||||
private List<Color> colorGradientList;
|
||||
private void Awake()
|
||||
{
|
||||
text = transform.Find("Text").GetComponent<Text>();
|
||||
slider = transform.GetComponent<Slider>();
|
||||
text.text = $"{(slider.value * 100).ToString("#0")}%";
|
||||
//text.text = $"{(slider.value * 100).ToString("#0")}";
|
||||
//slider.onValueChanged.AddListener((f) =>
|
||||
//{
|
||||
// text.text = $"{valueHandler(f).ToString("#0")}";
|
||||
//});
|
||||
colorGradientList = SetColorGradient(new List<Color>
|
||||
{
|
||||
Utils.HexToColorHtml("#ffffff"),
|
||||
Utils.HexToColorHtml("#27DFE3"),
|
||||
Utils.HexToColorHtml("#27E363"),
|
||||
Utils.HexToColorHtml("#E3D427"),
|
||||
Utils.HexToColorHtml("#E33B27"),
|
||||
},
|
||||
new List<int>
|
||||
{
|
||||
50,50,100,100
|
||||
});
|
||||
}
|
||||
public bool runCallback = false;
|
||||
public void SetValueChanged(System.Action<float> a)
|
||||
{
|
||||
slider = transform.GetComponent<Slider>();
|
||||
slider.onValueChanged.RemoveAllListeners();
|
||||
slider.onValueChanged.AddListener((f) =>
|
||||
{
|
||||
text.text = $"{(f * 100).ToString("#0")}%";
|
||||
var step = 1f / (colorGradientList.Count-1);
|
||||
var index = (int)Math.Round(f / step, 0);
|
||||
slider.targetGraphic.color = colorGradientList[index];
|
||||
text.text = $"{valueHandler(f).ToString("#0")}";
|
||||
a.Invoke(f);
|
||||
});
|
||||
}
|
||||
public void SetValue(float a)
|
||||
{
|
||||
slider.value = a;
|
||||
}
|
||||
|
||||
public List<Color> SetColorGradient(List<Color> list, int divideCount)
|
||||
{
|
||||
var res = new List<Color>();
|
||||
for (int i = 0; i < list.Count - 1; i++)
|
||||
{
|
||||
Color c = list[i], nc = list[i + 1];
|
||||
var diff = new Tuple<float, float, float>((nc.r - c.r) / divideCount, (nc.g - c.g) / divideCount, (nc.b - c.b) / divideCount);
|
||||
for (int j = 0; j < divideCount; j++)
|
||||
{
|
||||
res.Add(new Color(c.r + diff.Item1 * j, c.g + diff.Item2 * j, c.b + diff.Item3 * j));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<Color> SetColorGradient(List<Color> list, List<int> divideList)
|
||||
{
|
||||
if (list.Count != divideList.Count+1) return null;
|
||||
var res = new List<Color>();
|
||||
for (int i = 0; i < list.Count - 1; i++)
|
||||
{
|
||||
Color c = list[i], nc = list[i + 1];
|
||||
var divideCount = divideList[i];
|
||||
var diff = new Tuple<float, float, float>((nc.r - c.r) / divideCount, (nc.g - c.g) / divideCount, (nc.b - c.b) / divideCount);
|
||||
for (int j = 0; j < divideCount; j++)
|
||||
{
|
||||
res.Add(new Color(c.r + diff.Item1 * j, c.g + diff.Item2 * j, c.b + diff.Item3 * j));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Assets.Scripts.UI.Control
|
||||
private Text text;
|
||||
//private Texture2D cursor;
|
||||
private Outline outline;
|
||||
private Button mButton;
|
||||
public Button mButton { get;set; }
|
||||
private Sequence se = null;
|
||||
private Sequence a;
|
||||
private TweenerCore<float, float, FloatOptions> b;
|
||||
|
||||
Reference in new issue
Block a user