分离具体属性组件,加入样式表系统
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a12c0014da358274285d451595dcf212
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 174ea317a2a5e8e44a0d96c6d7e43bd5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-1
@@ -26,7 +26,7 @@ namespace XericUI.ReflectionUIGenerator
|
||||
_ => typeof(object)
|
||||
};
|
||||
|
||||
IsReadOnly = memberInfo is PropertyInfo pi && !pi.CanWrite;
|
||||
IsReadOnly = memberInfo is PropertyInfo pi2 && !pi2.CanWrite;
|
||||
}
|
||||
|
||||
public object GetValue()
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74ef75bd607ec5242a6bb9bb985bf436
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+5
@@ -23,6 +23,11 @@ namespace XericUI.ReflectionUIGenerator
|
||||
{
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
public XuiavrgFieldDropdownValueAttribute(PresetOptionsMergeMode mergeMode, params string[] options)
|
||||
{
|
||||
MergeMode = mergeMode;
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
public void BindMetaData(AvrgMemberMetaData metaData)
|
||||
{
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 917ba2bd8d59cce469d2c90b2201c529
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+5
@@ -23,6 +23,11 @@ namespace XericUI.ReflectionUIGenerator
|
||||
{
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
public XuiavrgFieldToggleGroupValueAttribute(PresetOptionsMergeMode mergeMode, params string[] options)
|
||||
{
|
||||
MergeMode = mergeMode;
|
||||
Options = options ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
public void BindMetaData(AvrgMemberMetaData metaData)
|
||||
{
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6dac053ad1c4ab043a815cb9b3c64d06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+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:
|
||||
@@ -29,6 +29,12 @@ namespace XericUI.ReflectionUIGenerator
|
||||
/// <summary>值类型</summary>
|
||||
public Type ValueType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 样式表命名空间(用于 SuperStyleSheet 样式查询)
|
||||
/// 默认 "default"。可由类级或字段级 [XuiavrgStyleNamespace] 覆写
|
||||
/// </summary>
|
||||
public string StyleNamespace { get; set; } = "default";
|
||||
|
||||
// ============ UI 映射 ============
|
||||
|
||||
/// <summary>功能标记</summary>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a2aac04058602749be2f5153db24b69
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6a7d2f0806496e45b383e7d26eca214
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -85,6 +85,20 @@ namespace XericUI.ReflectionUIGenerator
|
||||
|
||||
#endregion
|
||||
|
||||
#region Unity 生命周期
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
XuiavrgStyleDefaults.EnsureDefaults();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearAll();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 核心生命周期
|
||||
|
||||
public void BuildFromMetaDataSet(AvrgMemberMetaDataSet metaDataSet,
|
||||
@@ -443,12 +457,5 @@ namespace XericUI.ReflectionUIGenerator
|
||||
|
||||
_leafGroupMap.Clear();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearAll();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -35,6 +35,11 @@ namespace XericUI.ReflectionUIGenerator
|
||||
|
||||
var metaDataSet = new AvrgMemberMetaDataSet();
|
||||
|
||||
// ★ 收集类级别 IXuiavrgAttribute — 作为所有字段的基础模板
|
||||
var classAttributes = type.GetCustomAttributes()
|
||||
.OfType<IXuiavrgAttribute>()
|
||||
.ToList();
|
||||
|
||||
foreach (var memberInfo in type.GetRuntimeMemberInfo())
|
||||
{
|
||||
// 检查隐藏标记
|
||||
@@ -59,16 +64,22 @@ namespace XericUI.ReflectionUIGenerator
|
||||
PropertyCheckKey = valueType?.FullName,
|
||||
};
|
||||
|
||||
// 收集并执行所有 IXuiavrgAttribute
|
||||
var attributes = memberInfo.GetCustomAttributes()
|
||||
// ★ 第1步: 先应用类级特性(设置默认值)
|
||||
foreach (var classAttr in classAttributes)
|
||||
{
|
||||
classAttr.BindMetaData(metaData);
|
||||
}
|
||||
|
||||
// ★ 第2步: 再应用字段级特性(可覆盖类级设置)
|
||||
var fieldAttributes = memberInfo.GetCustomAttributes()
|
||||
.OfType<IXuiavrgAttribute>()
|
||||
.ToList();
|
||||
|
||||
metaData.Attributes = attributes;
|
||||
metaData.Attributes = fieldAttributes;
|
||||
|
||||
foreach (var attr in attributes)
|
||||
foreach (var fieldAttr in fieldAttributes)
|
||||
{
|
||||
attr.BindMetaData(metaData);
|
||||
fieldAttr.BindMetaData(metaData);
|
||||
}
|
||||
|
||||
metaDataSet.Add(metaData);
|
||||
|
||||
Reference in New Issue
Block a user