diff --git a/Assets/UIView/EquipmentSimulationView/Resources/EquipmentSimulationView.prefab b/Assets/UIView/EquipmentSimulationView/Resources/EquipmentSimulationView.prefab index 88a673e..fa3b02f 100644 --- a/Assets/UIView/EquipmentSimulationView/Resources/EquipmentSimulationView.prefab +++ b/Assets/UIView/EquipmentSimulationView/Resources/EquipmentSimulationView.prefab @@ -11042,7 +11042,7 @@ MonoBehaviour: objectValue: {fileID: 5627652597274816387} dataValue: variableType: 10 - - name: "\u65F6\u957F\u8F93\u5165\u6846" + - name: "\u8FD0\u884C\u65F6\u957F\u8F93\u5165\u6846" objectValue: {fileID: 5627652595602229817} dataValue: variableType: 10 @@ -15539,8 +15539,8 @@ MonoBehaviour: allowNegative: 0 allowEmpty: 0 maxDecimalPlaces: 1 - minValue: -15 - maxValue: 55 + minValue: 16 + maxValue: 32 --- !u!1 &5627652596662180239 GameObject: m_ObjectHideFlags: 0 @@ -17828,7 +17828,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: "\u6E29\u5EA6\u8303\u56F4(-15\u2103~55\u2103)" + m_Text: "\u6E29\u5EA6\u8303\u56F4(16\u2103~32\u2103)" --- !u!1 &5627652596936877788 GameObject: m_ObjectHideFlags: 0 @@ -23919,7 +23919,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &2218283927450267575 RectTransform: m_ObjectHideFlags: 0 @@ -23957,7 +23957,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 448, y: -11} + m_AnchoredPosition: {x: -650, y: -359.76} m_SizeDelta: {x: 580, y: 300} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &3579183680715366806 diff --git a/Assets/Zion/Scripts/NumberInputField.cs b/Assets/Zion/Scripts/NumberInputField.cs index e4299a7..22592f7 100644 --- a/Assets/Zion/Scripts/NumberInputField.cs +++ b/Assets/Zion/Scripts/NumberInputField.cs @@ -18,13 +18,13 @@ public class NumberInputField : MonoBehaviour [Header("输入规则")] [Tooltip("是否允许输入小数(小数点)")] public bool allowDecimal = true; - + [Tooltip("是否允许输入负数")] public bool allowNegative = false; - + [Tooltip("是否允许为空")] public bool allowEmpty = true; - + [Tooltip("小数点后最多几位(0表示不限制)")] [Range(0, 10)] public int maxDecimalPlaces = 2; @@ -38,11 +38,12 @@ public class NumberInputField : MonoBehaviour private string previousValidText = ""; private InputField legacyInputField; - #if TMP_PRESENT +#if TMP_PRESENT private TMP_InputField tmpInputField; - #endif +#endif private bool isInitialized = false; + void Start() { InitializeInputField(); @@ -68,7 +69,7 @@ public class NumberInputField : MonoBehaviour { targetInputField = legacyInputField; } - #if TMP_PRESENT +#if TMP_PRESENT else { tmpInputField = GetComponent(); @@ -77,17 +78,17 @@ public class NumberInputField : MonoBehaviour targetInputField = tmpInputField; } } - #endif +#endif } else { - legacyInputField = targetInputField as InputField; - #if TMP_PRESENT + legacyInputField = targetInputField.GetComponent(); +#if TMP_PRESENT if (legacyInputField == null) { - tmpInputField = targetInputField as TMP_InputField; + tmpInputField = targetInputField.GetComponent(); } - #endif +#endif } if (targetInputField == null) @@ -100,15 +101,15 @@ public class NumberInputField : MonoBehaviour if (legacyInputField != null) { previousValidText = legacyInputField.text; - legacyInputField.onValueChanged.AddListener(OnInputValueChanged); + legacyInputField.onEndEdit.AddListener(OnInputValueChanged); } - #if TMP_PRESENT +#if TMP_PRESENT else if (tmpInputField != null) { previousValidText = tmpInputField.text; - tmpInputField.onValueChanged.AddListener(OnInputValueChanged); + tmpInputField.onEndEdit.AddListener(OnInputValueChanged); } - #endif +#endif isInitialized = true; } @@ -200,7 +201,7 @@ public class NumberInputField : MonoBehaviour // 3. 检查小数点和数字 bool hasDecimalPoint = false; int decimalPlaces = 0; - + for (int i = 0; i < str.Length; i++) { char c = str[i]; @@ -213,7 +214,7 @@ public class NumberInputField : MonoBehaviour if (!allowDecimal) return false; // 不允许小数 if (hasDecimalPoint) return false; // 已经有一个小数点了 hasDecimalPoint = true; - + // 小数点不能是唯一字符(除非前面有符号) if (i == 0 || (i == 1 && (str[0] == '-' || str[0] == '+'))) { @@ -248,10 +249,10 @@ public class NumberInputField : MonoBehaviour private bool HasTooManyDecimalPlaces(string str) { if (maxDecimalPlaces <= 0 || !allowDecimal) return false; - + int decimalIndex = str.IndexOf('.'); if (decimalIndex == -1) return false; - + int decimalPlaces = str.Length - decimalIndex - 1; return decimalPlaces > maxDecimalPlaces; } @@ -262,15 +263,15 @@ public class NumberInputField : MonoBehaviour private string TruncateDecimalPlaces(string str) { if (maxDecimalPlaces <= 0) return str; - + int decimalIndex = str.IndexOf('.'); if (decimalIndex == -1) return str; - + if (decimalIndex + 1 + maxDecimalPlaces < str.Length) { return str.Substring(0, decimalIndex + 1 + maxDecimalPlaces); } - + return str; } @@ -292,12 +293,12 @@ public class NumberInputField : MonoBehaviour { legacyInputField.text = text; } - #if TMP_PRESENT +#if TMP_PRESENT else if (tmpInputField != null) { tmpInputField.text = text; } - #endif +#endif } /// @@ -318,12 +319,12 @@ public class NumberInputField : MonoBehaviour { text = legacyInputField.text; } - #if TMP_PRESENT +#if TMP_PRESENT else if (tmpInputField != null) { text = tmpInputField.text; } - #endif +#endif if (string.IsNullOrEmpty(text) || text == "-" || text == "+" || text == ".") { @@ -363,7 +364,7 @@ public class NumberInputField : MonoBehaviour { text = clampedValue.ToString("F" + maxDecimalPlaces); } - + SetInputFieldText(text); previousValidText = text; } @@ -399,11 +400,11 @@ public class NumberInputField : MonoBehaviour { legacyInputField.onValueChanged.RemoveListener(OnInputValueChanged); } - #if TMP_PRESENT +#if TMP_PRESENT if (tmpInputField != null) { tmpInputField.onValueChanged.RemoveListener(OnInputValueChanged); } - #endif +#endif } } diff --git a/Assets/Zion/Scripts/UIView/EquipmentSimulationView.cs b/Assets/Zion/Scripts/UIView/EquipmentSimulationView.cs index 5d329e1..2ee1c30 100644 --- a/Assets/Zion/Scripts/UIView/EquipmentSimulationView.cs +++ b/Assets/Zion/Scripts/UIView/EquipmentSimulationView.cs @@ -215,7 +215,7 @@ public class EquipmentSimulationView : UIView #region 切换设备 - void InitLeftBtns() + void InitLeftBtns() { // 初始化字典 @@ -235,7 +235,7 @@ public class EquipmentSimulationView : UIView { SetSelectedButton(deviceBtns[0]); } - } + } private void OnButtonSelected(Button selectedButton, int index) { @@ -352,7 +352,7 @@ public class EquipmentSimulationView : UIView /**/ variables.Get