Skip to content

Commit a001d3b

Browse files
committed
Support properties for UIComponent and UIObject
1 parent 45773fd commit a001d3b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

BeatSaberMarkupLanguage/BSMLParser.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ private void HandleTagNode(XElement element, GameObject parent, BSMLParserParams
380380

381381
object host = parserParams.Host;
382382
XAttribute id = element.Attribute("id");
383+
384+
// TODO: iterating over fields/properties for every tag is very inefficient
383385
if (host != null && id != null)
384386
{
385387
foreach (FieldInfo fieldInfo in host.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
@@ -394,6 +396,19 @@ private void HandleTagNode(XElement element, GameObject parent, BSMLParserParams
394396
fieldInfo.SetValue(host, currentNode);
395397
}
396398
}
399+
400+
foreach (PropertyInfo fieldInfo in host.GetType().GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public))
401+
{
402+
if (fieldInfo.GetCustomAttribute<UIComponent>(true)?.Id == id.Value)
403+
{
404+
fieldInfo.SetValue(host, GetExternalComponent(currentNode, fieldInfo.PropertyType));
405+
}
406+
407+
if (fieldInfo.GetCustomAttribute<UIObject>(true)?.Id == id.Value)
408+
{
409+
fieldInfo.SetValue(host, currentNode);
410+
}
411+
}
397412
}
398413

399414
XAttribute tags = element.Attribute("tags");

0 commit comments

Comments
 (0)