Automatic rename UIControl Items

See #213
This commit is contained in:
stefnotch
2021-02-19 12:55:22 +01:00
parent cc980fd70d
commit 3964fc7795
2 changed files with 18 additions and 7 deletions

View File

@@ -405,7 +405,13 @@ namespace FlaxEditor.CustomEditors.Dedicated
for (int i = 0; i < uiControls.Count; i++)
{
var uiControl = (UIControl)uiControls[i];
string previousName = uiControl.Control?.GetType()?.Name ?? typeof(UIControl).Name;
uiControl.Control = (Control)controlType.CreateInstance();
if (uiControl.Name.StartsWith(previousName))
{
string newName = controlType.Name + uiControl.Name.Substring(previousName.Length);
uiControl.Name = StringUtils.IncrementNameNumber(newName, x => uiControl.Parent.GetChild(x) == null);
}
}
}
}
@@ -414,7 +420,13 @@ namespace FlaxEditor.CustomEditors.Dedicated
for (int i = 0; i < uiControls.Count; i++)
{
var uiControl = (UIControl)uiControls[i];
string previousName = uiControl.Control?.GetType()?.Name ?? typeof(UIControl).Name;
uiControl.Control = (Control)controlType.CreateInstance();
if (uiControl.Name.StartsWith(previousName))
{
string newName = controlType.Name + uiControl.Name.Substring(previousName.Length);
uiControl.Name = StringUtils.IncrementNameNumber(newName, x => uiControl.Parent.GetChild(x) == null);
}
}
}