Skip to content

Commit

Permalink
Destroy array list UI if it becomes driven
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra authored and Banane9 committed Sep 5, 2024
1 parent 5d20d85 commit 0a39028
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion MonkeyLoader.Resonite.Integration/UI/SyncArrayEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,23 @@ private static bool Prefix(ISyncArray array, string name, FieldInfo fieldInfo, U
if (!array.IsDriven)
{
SyncMemberEditorBuilder.BuildList(list, name, listField, ui);
ui.Current[ui.Current.ChildrenCount - 1].DestroyWhenLocalUserLeaves();
var listSlot = ui.Current;
listSlot.DestroyWhenLocalUserLeaves();
void ArrayChanged(IChangeable changeable)
{
if (((ISyncArray)changeable).IsDriven)
{
listSlot.DestroyChildren();
listSlot.Components.ToArray().Do((Component c) => c.Destroy());
listSlot.AttachComponent<LayoutElement>().MinHeight.Value = 24f;
var newUi = new UIBuilder(listSlot, listSlot);
RadiantUI_Constants.SetupEditorStyle(newUi);
newUi.Text("(array is driven)");
proxySlot?.Destroy();
array.Changed -= ArrayChanged;
}
}
array.Changed += ArrayChanged;
}
else
{
Expand Down

0 comments on commit 0a39028

Please sign in to comment.