添加了更多的反射检查逻辑。

修复布局组件的缓存引用关系
This commit is contained in:
2026-04-28 17:13:23 +08:00
parent bcb13638c1
commit 5f93152c9b
20 changed files with 212 additions and 57 deletions
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 29bdb71088ff44dd85e7485c8df8cd69
timeCreated: 1777358662
@@ -13,7 +13,6 @@ namespace XericUI.ReflectionUIGenerator
public readonly string LabelName;
public readonly string UIPropertyName;
public readonly string UnitLabelName;
public readonly bool MustFillIn;
public readonly int InspectorOrder;
public readonly string GroupName;
public readonly string OnTriggerCall;
@@ -30,13 +29,12 @@ namespace XericUI.ReflectionUIGenerator
/// <param name="groupName">属性组名称(可以是以/&\分割的路径)</param>
/// <param name="onTriggerCall">属性附加的动作,调用此内联反射调用的函数</param>
/// <param name="size">属性组名称(可以是以/&\分割的路径)</param>
public XuiavrgAttribute(string labelName, string uiPropertyName, string unitLabelName, bool mustFillin,
public XuiavrgAttribute(string labelName, string uiPropertyName, string unitLabelName,
int inspectorOrder = 0, string groupName = null, string onTriggerCall = "", XuiavrgSize size = XuiavrgSize.Normal)
{
LabelName = labelName;
UIPropertyName = uiPropertyName;
UnitLabelName = unitLabelName;
MustFillIn = mustFillin;
InspectorOrder = inspectorOrder;
GroupName = groupName;
OnTriggerCall = onTriggerCall;
@@ -52,7 +50,6 @@ namespace XericUI.ReflectionUIGenerator
property.labelName = LabelName;
property.uiPropertyName = UIPropertyName;
property.unitLabelName = UnitLabelName;
property.mustFillIn = MustFillIn;
property.inspectorOrder = InspectorOrder;
property.groupName = GroupName;
property.onTriggerCall = OnTriggerCall;
@@ -0,0 +1,28 @@
using System;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 集合检查
/// </summary>
public class XuiavrgCollectionCheckAttribute : Attribute, IXuiavrgAttribute
{
public readonly int minCount;
public readonly int maxCount;
public readonly bool notEmpty;
public XuiavrgCollectionCheckAttribute(int minCount, int maxCount, bool notEmpty)
{
this.minCount = minCount;
this.maxCount = maxCount;
this.notEmpty = notEmpty;
}
public void BindProperty(XuiavrgInspectorProperty property)
{
property.collectionMinCount = minCount;
property.collectionMaxCount = maxCount;
property.collectionNotEmpty = notEmpty;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4ec4224cb3844c439dd5fdb6b31c9730
timeCreated: 1777363387
@@ -0,0 +1,15 @@
using System;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 不可为空
/// </summary>
public class XuiavrgNotEmptyAttribute : Attribute, IXuiavrgAttribute
{
public void BindProperty(XuiavrgInspectorProperty property)
{
property.notEmpty = true;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 89e35e544d66421c8cc524d3b4d7b943
timeCreated: 1777360693
@@ -0,0 +1,25 @@
using System;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 数值检查
/// </summary>
public class XuiavrgNumberCheckAttribute : Attribute, IXuiavrgAttribute
{
public readonly float minValue;
public readonly float maxValue;
public XuiavrgNumberCheckAttribute(float minValue, float maxValue)
{
this.minValue = minValue;
this.maxValue = maxValue;
}
public void BindProperty(XuiavrgInspectorProperty property)
{
property.numberMinValue = minValue;
property.numberMaxValue = maxValue;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d5b533c6d6ca4de8811adc3913d1fd9b
timeCreated: 1777362005
@@ -0,0 +1,16 @@
using System;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 必填
/// </summary>
public class XuiavrgRequiredAttribute : Attribute, IXuiavrgAttribute
{
public void BindProperty(XuiavrgInspectorProperty property)
{
property.required = true;
property.notEmpty = true;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bcc4b8b735e84251b11ef87e9fe5b2cb
timeCreated: 1777358718
@@ -0,0 +1,48 @@
using System;
using UnityEngine;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 字符串检查
/// </summary>
public class XuiavrgStringCheckAttribute : Attribute, IXuiavrgAttribute
{
public readonly int minLength;
public readonly int maxLength;
public readonly string regexPattern;
public readonly bool onlyLetters;
public readonly bool onlyNumber;
public readonly bool onlyEmail;
public readonly bool onlyPhone;
public readonly bool onlyUrl;
public XuiavrgStringCheckAttribute(
int minLength = 0, int maxLength = int.MaxValue,
string regexPattern = "",
bool onlyLetters = false, bool onlyNumber = false, bool onlyEmail = true, bool onlyPhone = true,
bool onlyUrl = true)
{
this.minLength = minLength;
this.maxLength = maxLength;
this.regexPattern = regexPattern;
this.onlyLetters = onlyLetters;
this.onlyNumber = onlyNumber;
this.onlyEmail = onlyEmail;
this.onlyPhone = onlyPhone;
this.onlyUrl = onlyUrl;
}
public void BindProperty(XuiavrgInspectorProperty property)
{
property.stringMinLength = minLength;
property.stringMaxLength = maxLength;
property.stringRegexPattern = regexPattern;
property.stringOnlyLetters = onlyLetters;
property.stringOnlyNumber = onlyNumber;
property.stringOnlyEmail = onlyEmail;
property.stringOnlyPhone = onlyPhone;
property.stringOnlyUrl = onlyUrl;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0a0e34665ed24a7c87e5eb84a45f6ef6
timeCreated: 1777360997
@@ -1,5 +1,6 @@
using System;
using System.Reflection;
using UnityEngine;
using UnityEngine.Serialization;
namespace XericUI.ReflectionUIGenerator
@@ -10,22 +11,48 @@ namespace XericUI.ReflectionUIGenerator
[Serializable]
public class XuiavrgInspectorProperty
{
#region 字段属性
public object valueTarget;
public bool isProperty;
public PropertyInfo propertyInfo;
public FieldInfo fieldInfo;
public string labelName;
public string uiPropertyName;
public string unitLabelName;
public bool mustFillIn;
public int inspectorOrder;
public string groupName;
public string onTriggerCall;
public XuiavrgSize argumentSize;
public bool hideInInspector;
// 基本信息
public string labelName; // 字段名称
public string uiPropertyName; // ui属性名称
public string unitLabelName; // 单位名称
public bool required; // 项目必填
public bool notEmpty; // 不可为空
public int inspectorOrder; // 显示在检查器上的顺序
public string groupName; // 编组名称
public string onTriggerCall; // 值变更时触发的反射
public XuiavrgSize argumentSize; // 属性尺寸
public bool hideInInspector; // 在检查器上隐藏显示
// 字符串检查
public int stringMinLength; // 最小长度
public int stringMaxLength = int.MaxValue; // 最大长度
public string stringRegexPattern = ""; // 正则检查
public bool stringOnlyLetters; // 允许字符
public bool stringOnlyNumber; // 允许数字
public bool stringOnlyEmail = true; // 允许邮箱
public bool stringOnlyPhone = true; // 允许电话号码
public bool stringOnlyUrl = true; // 允许网址
// 数值检查
public float numberMinValue; // 最小值
public float numberMaxValue; // 最大值
// 集合检查
public int collectionMinCount; // 集合的最小尺寸
public int collectionMaxCount = int.MaxValue; // 集合的最大尺寸
public bool collectionNotEmpty; // 集合不可为空
#endregion
#region 检查方法
/// <summary>
/// 绑定到数据端
/// </summary>
@@ -138,5 +165,7 @@ namespace XericUI.ReflectionUIGenerator
public void Clear()
{
}
#endregion
}
}