Skip to content

Commit 722ef2b

Browse files
committed
feat(UI): 为OptionUIConfigAttribute添加IsResource属性
当UI配置标记为资源路径时,将uiFormAssetPath设置为"UI",以支持从资源路径加载UI表单。
1 parent cb9620e commit 722ef2b

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Runtime/Attribute/OptionUIConfigAttribute.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ public sealed class OptionUIConfigAttribute : Attribute
5050
/// </summary>
5151
public string Path { get; private set; }
5252

53+
/// <summary>
54+
/// 是否为资源路径。若为 true,则 Path 为资源路径;若为 false,则 Path 为 UI 预制体路径。
55+
/// </summary>
56+
public bool IsResource { get; private set; }
57+
5358
/// <summary>
5459
/// 构造 UI 配置特性。
5560
/// </summary>
@@ -65,5 +70,14 @@ public OptionUIConfigAttribute(string packageName = null, string path = null)
6570
throw new Exception("PackageName or Path is null");
6671
}
6772
}
73+
74+
/// <summary>
75+
/// 构造 UI 配置特性。
76+
/// </summary>
77+
/// <param name="isResource">是否为资源路径。若为 true,则 Path 为资源路径;若为 false,则 Path 为 UI 预制体路径。</param>
78+
public OptionUIConfigAttribute(bool isResource = false)
79+
{
80+
IsResource = isResource;
81+
}
6882
}
6983
}

Runtime/UIComponent.Open.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ public async Task<T> OpenAsync<T>(object userData = null, bool isFullScreen = fa
152152
{
153153
uiFormAssetPath = optionUIConfig.Path;
154154
}
155+
156+
if (optionUIConfig.IsResource)
157+
{
158+
uiFormAssetPath = "UI";
159+
}
155160
}
156161

157162
return await OpenAsync<T>(uiFormAssetPath, userData, isFullScreen);

0 commit comments

Comments
 (0)