Merge branch 'develop' into 开头优化5.16.15.51
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.Localization.Settings;
|
||||
|
||||
/*
|
||||
//Set properties in C# example codes.
|
||||
using RainbowArt.CleanFlatUI;
|
||||
public class ProgressBarGridCircularDemo : MonoBehaviour
|
||||
{
|
||||
{
|
||||
//The ProgressBarGridCircular Component.
|
||||
public ProgressBarGridCircular m_ProgressBar;
|
||||
void Start()
|
||||
{
|
||||
{
|
||||
//Set the current value.
|
||||
m_ProgressBar.CurrentValue = 5;
|
||||
m_ProgressBar.CurrentValue = 5;
|
||||
//Set whether to show the text.
|
||||
m_ProgressBar.HasText = true;
|
||||
}
|
||||
m_ProgressBar.HasText = true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -25,42 +25,35 @@ namespace RainbowArt.CleanFlatUI
|
||||
{
|
||||
public class ProgressBarGridCircular : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
int currentValue = 0;
|
||||
[SerializeField] int currentValue = 0;
|
||||
|
||||
[SerializeField]
|
||||
int maxValue = 10;
|
||||
[SerializeField] int maxValue = 10;
|
||||
|
||||
[SerializeField]
|
||||
bool hasText = true;
|
||||
|
||||
[SerializeField]
|
||||
TextMeshProUGUI text;
|
||||
[SerializeField] bool hasText = true;
|
||||
|
||||
[SerializeField]
|
||||
RectTransform background;
|
||||
[SerializeField] TextMeshProUGUI text;
|
||||
|
||||
[SerializeField]
|
||||
RectTransform foreground;
|
||||
[SerializeField] RectTransform background;
|
||||
|
||||
[SerializeField]
|
||||
RectTransform bgTemplate;
|
||||
[SerializeField] RectTransform foreground;
|
||||
|
||||
[SerializeField]
|
||||
RectTransform fgTemplate;
|
||||
[SerializeField] RectTransform bgTemplate;
|
||||
|
||||
List<RectTransform> bgList = new List<RectTransform>();
|
||||
List<RectTransform> fgList = new List<RectTransform>();
|
||||
[SerializeField] RectTransform fgTemplate;
|
||||
|
||||
List<RectTransform> bgList = new List<RectTransform>();
|
||||
List<RectTransform> fgList = new List<RectTransform>();
|
||||
|
||||
public int CurrentValue
|
||||
{
|
||||
get => currentValue;
|
||||
set
|
||||
{
|
||||
if(currentValue == value)
|
||||
if (currentValue == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
currentValue = value;
|
||||
OnValueChanged();
|
||||
UpdateGUI();
|
||||
@@ -76,6 +69,7 @@ namespace RainbowArt.CleanFlatUI
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hasText = value;
|
||||
UpdateText();
|
||||
}
|
||||
@@ -83,22 +77,24 @@ namespace RainbowArt.CleanFlatUI
|
||||
|
||||
void OnValueChanged()
|
||||
{
|
||||
if(currentValue < 0)
|
||||
if (currentValue < 0)
|
||||
{
|
||||
currentValue = 0;
|
||||
}
|
||||
|
||||
if (maxValue < 0)
|
||||
{
|
||||
maxValue = 10;
|
||||
}
|
||||
if(currentValue > maxValue)
|
||||
|
||||
if (currentValue > maxValue)
|
||||
{
|
||||
currentValue = maxValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
{
|
||||
OnValueChanged();
|
||||
CreateList(bgList, background, bgTemplate);
|
||||
CreateList(fgList, foreground, fgTemplate);
|
||||
@@ -106,12 +102,12 @@ namespace RainbowArt.CleanFlatUI
|
||||
}
|
||||
|
||||
void UpdateGUI()
|
||||
{
|
||||
UpdateForeground();
|
||||
{
|
||||
UpdateForeground();
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
void CreateList( List<RectTransform> list, RectTransform rectParent, RectTransform template)
|
||||
void CreateList(List<RectTransform> list, RectTransform rectParent, RectTransform template)
|
||||
{
|
||||
template.gameObject.SetActive(false);
|
||||
float angle = 360f / (float)maxValue;
|
||||
@@ -119,15 +115,15 @@ namespace RainbowArt.CleanFlatUI
|
||||
{
|
||||
RectTransform item = CreateItem(rectParent, template, i);
|
||||
list.Add(item);
|
||||
item.localEulerAngles = new Vector3(0, 0, - angle * i);
|
||||
}
|
||||
item.localEulerAngles = new Vector3(0, 0, -angle * i);
|
||||
}
|
||||
}
|
||||
|
||||
RectTransform CreateItem(RectTransform rectParent, RectTransform template, int index)
|
||||
{
|
||||
GameObject obj = GameObject.Instantiate(template.gameObject, rectParent);
|
||||
obj.gameObject.SetActive(true);
|
||||
obj.gameObject.name = "item"+ (index + 1);
|
||||
obj.gameObject.name = "item" + (index + 1);
|
||||
RectTransform rectTrans = obj.GetComponent<RectTransform>();
|
||||
rectTrans.localScale = Vector3.one;
|
||||
rectTrans.localEulerAngles = Vector3.zero;
|
||||
@@ -137,28 +133,29 @@ namespace RainbowArt.CleanFlatUI
|
||||
|
||||
void UpdateForeground()
|
||||
{
|
||||
for(int i = 0; i < fgList.Count; i++)
|
||||
for (int i = 0; i < fgList.Count; i++)
|
||||
{
|
||||
RectTransform rectTrans = fgList[i];
|
||||
Image image=rectTrans.transform.GetChild(0).GetComponent<Image>();
|
||||
if(i < currentValue)
|
||||
{
|
||||
Image image = rectTrans.transform.GetChild(0).GetComponent<Image>();
|
||||
if (i < currentValue)
|
||||
{
|
||||
rectTrans.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rectTrans.gameObject.SetActive(false);
|
||||
}
|
||||
if(i<16)
|
||||
}
|
||||
|
||||
if (i < 16)
|
||||
{
|
||||
image.color=Color.Lerp(Color.green, Color.yellow, i/16f);
|
||||
image.color = Color.Lerp(Color.green, Color.yellow, i / 16f);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.color = Color.Lerp(Color.yellow, Color.red, (i - 16) / 16f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UpdateText()
|
||||
@@ -167,13 +164,21 @@ namespace RainbowArt.CleanFlatUI
|
||||
{
|
||||
text.gameObject.SetActive(hasText);
|
||||
}
|
||||
if (hasText && (text != null))
|
||||
|
||||
if (hasText && text != null)
|
||||
{
|
||||
//float val = (float)currentValue / (float)maxValue;
|
||||
//text.text = Mathf.FloorToInt(val * 100) + "%";
|
||||
|
||||
text.text=currentValue*500+" 马力";
|
||||
if (LocalizationSettings.SelectedLocale.Identifier.Code == "en")
|
||||
{
|
||||
text.text = currentValue * 500 + " RPM";
|
||||
}
|
||||
else
|
||||
{
|
||||
text.text = currentValue * 500 + " 转";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 560a88da2bbc70140bed167f0ba7fe37
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb01be13d6e88ca488dda82150319bfc
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 117dcc671050f5247bd8743b91ecaab7
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+36
-9
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user