补充旧装配岛项目中的修改

This commit is contained in:
2026-06-01 10:36:06 +08:00
parent d3eb238bd6
commit a71f9cfc93
38 changed files with 54057 additions and 206 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d98e03d6c3f900341838908516882fd0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,9 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace LRC
@@ -14,7 +12,7 @@ namespace LRC
public class ConfigDigitalInputField : ConfigSelectableItem
{
#region 属性字段
#if UNITY_EDITOR
public float editorInput;
#endif
@@ -32,14 +30,28 @@ namespace LRC
/// 增量
/// </summary>
public double delta = 1;
public TMP_InputField TargetInput
{
get
{
if (targetInput != null)
{
return targetInput;
}
Debug.LogError("输入目标不存在", this);
return null;
}
set => targetInput = value;
}
public override bool AllowInput
{
get => base.AllowInput;
set
{
if (targetInput != null)
targetInput.readOnly = !value;
if (TargetInput != null)
TargetInput.readOnly = !value;
if (digitalAddButton != null)
digitalAddButton.interactable = value;
if (digitalSubButton != null)
@@ -47,7 +59,7 @@ namespace LRC
base.AllowInput = value;
}
}
#endregion
#region 生命周期
@@ -56,35 +68,35 @@ namespace LRC
{
base.OnValidate();
#if UNITY_EDITOR
if (targetInput != null)
targetInput.text = editorInput.ToString();
if (TargetInput != null)
TargetInput.text = editorInput.ToString(numberFormat);
#endif
}
protected override void Awake()
{
base.Awake();
if (ReferenceEquals(targetInput, null))
if (ReferenceEquals(TargetInput, null))
{
Debug.LogError($"{name}配置项目条目的基本元素不存在");
Debug.LogError($"{name}配置项目条目的基本元素不存在", this);
return;
}
targetInput.onSelect.AddListener(a =>
TargetInput.onSelect.AddListener(a =>
{
WhenStartEdit();
});
targetInput.onValueChanged.AddListener(o =>
TargetInput.onValueChanged.AddListener(o =>
{
double value = 0;
if (double.TryParse(o, out value))
{
SetValue(value);
SetValue(value.ToString(numberFormat));
}
});
targetInput.onEndEdit.AddListener(delegate
TargetInput.onEndEdit.AddListener(delegate
{
WhenEndEdit();
});
});
if (!ReferenceEquals(digitalAddButton, null))
digitalAddButton.onClick.AddListener(delegate
{
@@ -100,7 +112,7 @@ namespace LRC
}
#endregion
#region 实现
protected override void SetValue(object newValue)
@@ -112,18 +124,18 @@ namespace LRC
{
base.RefreshValueWithoutEvent(CastDigitalNumber(newValue, minValue, maxValue, digits), forceSet);
}
protected override void Initialization_ChildConstruction(UIBehaviour component)
{
base.Initialization_ChildConstruction(component);
if (component is TMP_InputField inputField)
{
if (targetInput != null)
targetInput = inputField;
if (TargetInput != null)
TargetInput = inputField;
}
else if(component is Button button)
else if (component is Button button)
{
var name = component.transform.name;
switch (name)
@@ -145,9 +157,9 @@ namespace LRC
protected override void RefreshFormatValue(object newValue)
{
base.RefreshFormatValue(newValue);
targetInput.text = CastDigitalNumber(newValue).ToString(numberFormat);
TargetInput.text = CastDigitalNumber(newValue).ToString(numberFormat);
}
#endregion
}
}
@@ -1,11 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
using UnityEngine.UI;
using XericLibrary.Runtime.CustomEditor;
using XericLibrary.Runtime.MacroLibrary;
@@ -51,10 +49,10 @@ namespace LRC
/// <summary>
/// 当数值收到修改时,产生事件,其中值的含义是修改前的值
/// </summary>
public static event Action<ConfigSelectableItem, object> OnAnyValueChange;
public static event Action<ConfigSelectableItem, object> OnAnyValueChange;
#endregion
#region 静态成员
/// <summary>
@@ -66,7 +64,7 @@ namespace LRC
/// 项目列表有效成员的数量
/// </summary>
public static int ConfigItemListCount => ConfigItemList.Count;
/// <summary>
/// 获取
/// </summary>
@@ -74,7 +72,7 @@ namespace LRC
/// <returns></returns>
public static ConfigSelectableItem GetConfigItemByIndex(int index) => ConfigItemList[index];
public static IEnumerable<ConfigSelectableItem> ConfigItemLists => ConfigItemList;
private static bool autoUpdateValueAll;
/// <summary>
/// 自动更新所有数值
@@ -89,9 +87,9 @@ namespace LRC
autoUpdateValueAll = value;
}
}
#endregion
#region 状态
/// <summary>
@@ -147,7 +145,7 @@ namespace LRC
/// </code>
/// </summary>
public event Func<ConfigSelectableItem, bool> GetSourceValueAutoUpdate;
/// <summary>
/// 当前属性的自动更新请求设置
/// <code>
@@ -157,9 +155,9 @@ namespace LRC
/// </code>
/// </summary>
public event Action<bool> SetSourceValueAutoUpdate;
/// <summary>
/// 请求此属性设置值(将值应用到寄存中)
/// </summary>
@@ -167,9 +165,9 @@ namespace LRC
{
SetSourceValue?.Invoke(this, Value);
}
#endregion
#region 属性字段
/// <summary>
@@ -177,7 +175,7 @@ namespace LRC
/// </summary>
[Rename("映射标记")]
public string configTag;
/// <summary>
/// 设定是否有效。
/// 如果无效,则不允许输入
@@ -199,14 +197,14 @@ namespace LRC
[SerializeField]
[Rename("允许阻塞自动更新")]
private bool allowBlockUpdate = true;
/// <summary>
/// 阻塞自动更新,一般由程序自动根据焦点更新
/// </summary>
[SerializeField]
[Rename("阻塞自动更新")]
private bool forceBlockUpdate = false;
/// <summary>
/// 格式化文本
/// </summary>
@@ -253,7 +251,7 @@ namespace LRC
[Rename("反转自动更新状态")]
public bool autoUpdateValueReversalState;
/// <summary>
/// 脏属性自动复位。
/// 当属性被重新开关时,将取消脏状态
@@ -262,7 +260,7 @@ namespace LRC
public bool dirtyAutoReset = false;
// ==== 属性 ==== //
/// <summary>
/// 设定是否输入有效
/// </summary>
@@ -295,13 +293,13 @@ namespace LRC
return;
}
if (!value) return;
_isDirty = true;
OnAnyValueDirty?.Invoke(this);
OnValueDirty?.Invoke(this);
}
}
/// <summary>
/// 设定自动更新状态,并同步选框
/// <code>
@@ -333,16 +331,20 @@ namespace LRC
public bool ForceBlockUpdate
{
get => forceBlockUpdate;
set => forceBlockUpdate = value;
set => forceBlockUpdate = value;
}
/// <summary>
/// 项目标题
/// </summary>
public string TitleName
{
get => titleLabel.text;
set => titleLabel.text = value;
set
{
if (titleLabel != null)
titleLabel.text = value;
}
}
/// <summary>
@@ -375,7 +377,7 @@ namespace LRC
get => unitLabel.text;
set => unitLabel.text = value;
}
[SerializeField]
// [Obsolete("请使用访问器")]
private object _value;
@@ -385,7 +387,7 @@ namespace LRC
/// </summary>
public object Value
{
get => _value;
get => _value;
protected set
{
if (IsValueInitNull && value != null)
@@ -395,11 +397,11 @@ namespace LRC
}
// ==== 暂存 ==== //
public FieldInfo FieldInfo;
public Type FieldType;
#endregion
#region 生命周期
@@ -431,7 +433,7 @@ namespace LRC
ConfigItemList.Add(this);
ForceUpdateAllConfigEvent += ForceUpdate;
ForceSetAllSourceValueEvent += SetSourceValueRequest;
if (dirtyAutoReset)
IsDirty = false;
}
@@ -535,9 +537,9 @@ namespace LRC
_ => Vector3.zero
};
}
#endregion
#region 初始化方法
/// <summary>
@@ -600,7 +602,7 @@ namespace LRC
#endregion
#region 更新方法
/// <summary>
/// 更新函数
/// <code>
@@ -614,7 +616,7 @@ namespace LRC
IsDirty = false;
var value = GetSourceValue?.Invoke(this);
if (value == null)
return ;
return;
RefreshValueWithoutEvent(value, forceSet);
RefreshAutoUpdateValue();
}
@@ -665,15 +667,15 @@ namespace LRC
{
var isSourceValueAutoUpdate = GetSourceValueAutoUpdate?.Invoke(this);
if (isSourceValueAutoUpdate != null)
AutoUpdateValue = isSourceValueAutoUpdate.Value;
AutoUpdateValue = isSourceValueAutoUpdate.Value;
}
/// <summary>
/// 刷新格式化文本,在触发刷新时将产生更新
/// </summary>
protected virtual void RefreshFormatValue(object newValue)
{
}
protected void WhenStartEdit()
@@ -681,7 +683,7 @@ namespace LRC
// Debug.Log("开始编辑");
ForceBlockUpdate = true;
}
/// <summary>
/// 数值输入完毕,或焦点移除时调用。
/// </summary>
@@ -691,7 +693,7 @@ namespace LRC
ForceBlockUpdate = false;
OnEndEdit?.Invoke(this, Value);
}
#endregion
#region 外观设定
@@ -705,7 +707,7 @@ namespace LRC
Destroy(autoUpdateValueToggle.gameObject);
this.autoUpdateValue = autoUpdateValueReversalState ^ autoUpdateValue;
}
#endregion
}
@@ -1,10 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace LRC
{
@@ -14,14 +9,19 @@ namespace LRC
public class ConfigTextInputField : ConfigSelectableItem
{
#region ÊôÐÔ×ÖÎ
#if UNITY_EDITOR
public string editorInput;
#endif
public TMP_InputField targetInput;
// 定义一个委托,接受字符串参数并返回布尔值
public delegate bool StringEventHandler(string input);
// 声明事件
public static event StringEventHandler 判断是否重名;
public override bool AllowInput
{
get => base.AllowInput;
@@ -53,19 +53,25 @@ namespace LRC
{
WhenStartEdit();
});
targetInput.onValueChanged.AddListener(o =>
targetInput.onEndEdit.AddListener(o =>
{
if(double.TryParse(o, out var value))
SetValue(value);
if (判断是否重名 != null)
{
if (判断是否重名.Invoke(o))
{
SetValue(o);
}
}
});
targetInput.onEndEdit.AddListener(delegate
{
WhenEndEdit();
});
}
#endregion
#region ʵÏÖ
protected override void SetValue(object newValue)
@@ -77,11 +83,11 @@ namespace LRC
{
base.RefreshValueWithoutEvent(newValue, forceSet);
}
protected override void Initialization_ChildConstruction(UIBehaviour component)
{
base.Initialization_ChildConstruction(component);
if (component is TMP_InputField inputField)
{
if (targetInput != null)
@@ -94,7 +100,7 @@ namespace LRC
base.RefreshFormatValue(newValue);
targetInput.text = newValue.ToString();
}
#endregion
}
}
@@ -78,6 +78,8 @@ namespace LRC
// toggle.isOn = true;
// Debug.Log(TitleName +":ÉèÖò¼¶ûÏîÄ¿");
// }
//toggles[newIndex].isOn = true;
toggles[newIndex].SetIsOnWithoutNotify(true);
}