Distinguish stepped sliders by applying a tint to them.

This commit is contained in:
2023-07-27 16:22:22 +08:00
parent d83f447e82
commit 98e35fc6f6
2 changed files with 12 additions and 7 deletions

View File

@@ -5,6 +5,8 @@ using UnityEngine.UI;
namespace Cryville.Crtr.Browsing {
public class PVPNumber : PropertyValuePanel {
static Color _steppedTint = new Color(1.0f, 0.8f, 0.5f);
double m_value;
public override object Value {
get {
@@ -42,7 +44,7 @@ namespace Cryville.Crtr.Browsing {
[SerializeField]
RectTransform m_handleArea;
[SerializeField]
RectTransform m_handle;
Image m_handle;
[SerializeField]
Text m_text;
#pragma warning disable IDE0051
@@ -60,7 +62,10 @@ namespace Cryville.Crtr.Browsing {
ev.callback.AddListener(e => OnPointerClick((PointerEventData)e));
m_ctn.triggers.Add(ev);
if (MaxStep != 0) SetRatio(0.5f);
if (MaxStep != 0) {
m_handle.color = _steppedTint;
SetRatio(0.5f);
}
}
void Update() {
@@ -71,7 +76,7 @@ namespace Cryville.Crtr.Browsing {
}
void OnRectTransformDimensionsChange() {
m_handleArea.sizeDelta = new Vector2(m_handle.rect.height - m_handle.rect.width, 0);
m_handleArea.sizeDelta = new Vector2(m_handle.rectTransform.rect.height - m_handle.rectTransform.rect.width, 0);
}
#pragma warning restore IDE0051
@@ -145,8 +150,8 @@ namespace Cryville.Crtr.Browsing {
}
void SetRatio(float ratio) {
m_handle.anchorMin = new Vector2(ratio, m_handle.anchorMin.y);
m_handle.anchorMax = new Vector2(ratio, m_handle.anchorMax.y);
m_handle.rectTransform.anchorMin = new Vector2(ratio, m_handle.rectTransform.anchorMin.y);
m_handle.rectTransform.anchorMax = new Vector2(ratio, m_handle.rectTransform.anchorMax.y);
}
}
}

View File

@@ -115,7 +115,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.000015258789, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &222075825141302810
@@ -381,5 +381,5 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_ctn: {fileID: 114711521343559538}
m_handleArea: {fileID: 224546415986473210}
m_handle: {fileID: 224224697565322868}
m_handle: {fileID: 114706336791114340}
m_text: {fileID: 114326201672791100}