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

修复布局组件的缓存引用关系
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,7 @@
namespace XericUI.ReflectionUIGenerator
{
public interface IXuiavrgAttribute
{
public void BindProperty(XuiavrgInspectorProperty property);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 998589d7b3414ddd99b69cb128d7e052
timeCreated: 1777014404
@@ -0,0 +1,75 @@
using System;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 反射属性标记
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class XuiavrgAttribute : Attribute, IXuiavrgAttribute
{
#region 字段属性
public readonly string LabelName;
public readonly string UIPropertyName;
public readonly string UnitLabelName;
public readonly int InspectorOrder;
public readonly string GroupName;
public readonly string OnTriggerCall;
public readonly XuiavrgSize ArgumentSize;
/// <summary>
/// 标记属性
/// </summary>
/// <param name="labelName">属性显示名称</param>
/// <param name="uiPropertyName">属性标记名(对应界面元素名称)</param>
/// <param name="unitLabelName">属性显示单位名称</param>
/// <param name="mustFillin">是否标记为必填项目</param>
/// <param name="inspectorOrder">属性显示顺序</param>
/// <param name="groupName">属性组名称(可以是以/&\分割的路径)</param>
/// <param name="onTriggerCall">属性附加的动作,调用此内联反射调用的函数</param>
/// <param name="size">属性组名称(可以是以/&\分割的路径)</param>
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;
InspectorOrder = inspectorOrder;
GroupName = groupName;
OnTriggerCall = onTriggerCall;
ArgumentSize = size;
}
#endregion
#region 生成器
public void BindProperty(XuiavrgInspectorProperty property)
{
property.labelName = LabelName;
property.uiPropertyName = UIPropertyName;
property.unitLabelName = UnitLabelName;
property.inspectorOrder = InspectorOrder;
property.groupName = GroupName;
property.onTriggerCall = OnTriggerCall;
property.argumentSize = ArgumentSize;
}
#endregion
}
/// <summary>
/// 属性尺寸
/// </summary>
public enum XuiavrgSize
{
None = 0,
Tiny = 1000 - 2,
Small = 1000 - 1,
Normal = 1000,
Big,
Large,
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 10e270c86cab4817a0b8ce7877b2ab88
timeCreated: 1776505683
@@ -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,28 @@
using System;
using UnityEngine.Serialization;
namespace XericUI.ReflectionUIGenerator
{
/// <summary>
/// 隐藏标记
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class XuiavrgHideAttribute : Attribute, IXuiavrgAttribute
{
public readonly bool Hide;
/// <summary>
/// 标记属性
/// </summary>
/// <param name="hideInInspector">隐藏属性</param>
public XuiavrgHideAttribute(bool hideInInspector = true)
{
Hide = hideInInspector;
}
public void BindProperty(XuiavrgInspectorProperty property)
{
property.hideInInspector = Hide;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 12f7aecaa5224304b1058ab9dc04a95f
timeCreated: 1776995602
@@ -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