Skip to content

Commit 56e1a58

Browse files
committed
[增加] UI组的标签识别
1 parent f39a5ca commit 56e1a58

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Runtime/FairyGUIFormHelper.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//------------------------------------------------------------
77

88
using System;
9+
using System.Reflection;
910
using FairyGUI;
1011
using GameFrameX.Asset.Runtime;
1112
using GameFrameX.Runtime;
@@ -21,6 +22,7 @@ namespace GameFrameX.UI.FairyGUI.Runtime
2122
public class FairyGUIFormHelper : UIFormHelperBase
2223
{
2324
private AssetComponent m_AssetComponent = null;
25+
private UIComponent m_UIComponent = null;
2426

2527
/// <summary>
2628
/// 实例化界面。
@@ -66,6 +68,15 @@ public override IUIForm CreateUIForm(object uiFormInstance, Type uiFormType, obj
6668

6769
var uiGroup = uiForm.UIGroup;
6870

71+
if (uiGroup == null)
72+
{
73+
var attribute = uiFormType.GetCustomAttribute(typeof(OptionUIGroup));
74+
if (attribute is OptionUIGroup optionUIGroup)
75+
{
76+
uiGroup = m_UIComponent.GetUIGroup(optionUIGroup.GroupName);
77+
}
78+
}
79+
6980
if (uiGroup == null)
7081
{
7182
Log.Error("UI group is invalid.");
@@ -111,6 +122,13 @@ private void Start()
111122
Log.Fatal("Asset component is invalid.");
112123
return;
113124
}
125+
126+
m_UIComponent = GameEntry.GetComponent<UIComponent>();
127+
if (m_UIComponent == null)
128+
{
129+
Log.Fatal("UI component is invalid.");
130+
return;
131+
}
114132
}
115133
}
116134
}

0 commit comments

Comments
 (0)