Merge remote-tracking branch 'gitea/master' into thr_dev/dev2
# Conflicts: # Runtime/InterfaceAttributeReflectionGenerator/Scripts/AvrgMemberMetaDataSet.cs
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
|
||||
namespace XericUI.ReflectionUIGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// 为 Dropdown UI 提供预设选项
|
||||
///
|
||||
/// 使用示例:
|
||||
/// [XuiavrgFieldDropdownValue("选项A", "选项B", "选项C", MergeMode = PresetOptionsMergeMode.Union)]
|
||||
/// public string quality = "选项A";
|
||||
///
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class XuiavrgFieldDropdownValueAttribute : Attribute, IXuiavrgAttribute
|
||||
{
|
||||
/// <summary>预设选项数组</summary>
|
||||
public readonly string[] Options;
|
||||
|
||||
/// <summary>与已有选项(如 enum 名)的合并模式</summary>
|
||||
public PresetOptionsMergeMode MergeMode { get; set; } = PresetOptionsMergeMode.Replace;
|
||||
|
||||
public XuiavrgFieldDropdownValueAttribute(params string[] options)
|
||||
{
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
public XuiavrgFieldDropdownValueAttribute(PresetOptionsMergeMode mergeMode, params string[] options)
|
||||
{
|
||||
MergeMode = mergeMode;
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
public void BindMetaData(AvrgMemberMetaData metaData)
|
||||
{
|
||||
if (metaData == null) return;
|
||||
|
||||
metaData.PresetOptions = Options;
|
||||
metaData.OptionsMergeMode = MergeMode;
|
||||
|
||||
// 自动设置 Tag 为 Dropdown
|
||||
if (metaData.Tag == XuiavrgFieldTag.None)
|
||||
metaData.Tag = XuiavrgFieldTag.Dropdown;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 917ba2bd8d59cce469d2c90b2201c529
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
|
||||
namespace XericUI.ReflectionUIGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// 为 ToggleGroup UI 提供预设选项
|
||||
///
|
||||
/// 使用示例:
|
||||
/// [XuiavrgFieldToggleGroupValue("低", "中", "高", MergeMode = PresetOptionsMergeMode.Replace)]
|
||||
/// public string detailLevel = "中";
|
||||
///
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class XuiavrgFieldToggleGroupValueAttribute : Attribute, IXuiavrgAttribute
|
||||
{
|
||||
/// <summary>预设选项数组</summary>
|
||||
public readonly string[] Options;
|
||||
|
||||
/// <summary>与已有选项(如 enum 名)的合并模式</summary>
|
||||
public PresetOptionsMergeMode MergeMode { get; set; } = PresetOptionsMergeMode.Replace;
|
||||
|
||||
public XuiavrgFieldToggleGroupValueAttribute(params string[] options)
|
||||
{
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
public XuiavrgFieldToggleGroupValueAttribute(PresetOptionsMergeMode mergeMode, params string[] options)
|
||||
{
|
||||
MergeMode = mergeMode;
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
public void BindMetaData(AvrgMemberMetaData metaData)
|
||||
{
|
||||
if (metaData == null) return;
|
||||
|
||||
metaData.PresetOptions = Options;
|
||||
metaData.OptionsMergeMode = MergeMode;
|
||||
|
||||
// 自动设置 Tag 为 ToggleGroup
|
||||
if (metaData.Tag == XuiavrgFieldTag.None)
|
||||
metaData.Tag = XuiavrgFieldTag.ToggleGroup;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dac053ad1c4ab043a815cb9b3c64d06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+2
-5
@@ -8,12 +8,11 @@ namespace XericUI.ReflectionUIGenerator
|
||||
/// 将一个复合类型(如 Vector2)拆分为多个子属性,分别绑定到不同的 UI 元素
|
||||
///
|
||||
/// 使用示例:
|
||||
/// [XuiavrgFieldEntryGroup("speed")]
|
||||
/// [XuiavrgSplit("x", "最小")]
|
||||
/// [XuiavrgSplit("y", "最大")]
|
||||
/// public Vector2 speedRange = new Vector2(0, 100);
|
||||
///
|
||||
/// 上述代码创建一个 "speed" 编组的 Entry,内部包含两个子绑定:
|
||||
/// 上述代码创建一个编组 Entry,内部包含两个子元数据:
|
||||
/// speedRange.x 绑定到 UI 的"最小"输入,speedRange.y 绑定到"最大"输入
|
||||
/// 子绑定通过 XUIAvrgMDValue.BindingSlots 与预制体上的 UI 组件匹配
|
||||
/// </summary>
|
||||
@@ -39,13 +38,12 @@ namespace XericUI.ReflectionUIGenerator
|
||||
|
||||
public void BindMetaData(AvrgMemberMetaData metaData)
|
||||
{
|
||||
// 创建子元数据
|
||||
// 创建子元数据 — 纯元数据,不持有实例
|
||||
var subMetaData = new AvrgMemberMetaData
|
||||
{
|
||||
MemberName = $"{metaData.MemberName}.{PropertyPath}",
|
||||
PropertyPath = PropertyPath,
|
||||
LabelName = DisplayLabel ?? PropertyPath,
|
||||
TargetInstance = null, // 由运行时闭包解析
|
||||
Hide = metaData.Hide,
|
||||
Required = metaData.Required,
|
||||
FieldOrder = metaData.FieldOrder,
|
||||
@@ -74,7 +72,6 @@ namespace XericUI.ReflectionUIGenerator
|
||||
if (parentType == null || string.IsNullOrEmpty(propertyPath))
|
||||
return null;
|
||||
|
||||
// 仅支持单层路径
|
||||
if (propertyPath.Contains('/'))
|
||||
return null;
|
||||
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
|
||||
namespace XericUI.ReflectionUIGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// 样式命名空间特性 — 为元数据指定 SuperStyleSheet 查询时的命名空间。
|
||||
///
|
||||
/// 可标记在类上(作为该类型所有字段的默认命名空间),
|
||||
/// 也可标记在字段/属性上(覆盖单个字段的命名空间)。
|
||||
///
|
||||
/// 类级标记先应用(设置默认值),字段级标记后应用(可覆盖),
|
||||
/// 因此字段级 [XuiavrgStyleNamespace] 优先于类级。
|
||||
///
|
||||
/// 默认命名空间为 "default"。
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class XuiavrgStyleNamespaceAttribute : Attribute, IXuiavrgAttribute
|
||||
{
|
||||
public readonly string StyleNamespace;
|
||||
|
||||
/// <param name="styleNamespace">SuperStyleSheet 命名空间名称(如 "my-theme")</param>
|
||||
public XuiavrgStyleNamespaceAttribute(string styleNamespace)
|
||||
{
|
||||
StyleNamespace = styleNamespace;
|
||||
}
|
||||
|
||||
public void BindMetaData(AvrgMemberMetaData metaData)
|
||||
{
|
||||
if (metaData != null)
|
||||
metaData.StyleNamespace = StyleNamespace;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee38b82f1ec947d4da1981bac698fe96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user