@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -244,8 +244,8 @@ namespace FlaxEngine
|
||||
return new string(charArray);
|
||||
}
|
||||
|
||||
private static readonly Regex IncNameRegex1 = new Regex("^(\\d+)");
|
||||
private static readonly Regex IncNameRegex2 = new Regex("^\\)(\\d+)\\(");
|
||||
private static readonly Regex IncNameRegex1 = new Regex("(\\d+)$");
|
||||
private static readonly Regex IncNameRegex2 = new Regex("\\((\\d+)\\)$");
|
||||
|
||||
/// <summary>
|
||||
/// Tries to parse number in the name brackets at the end of the value and then increment it to create a new name.
|
||||
@@ -264,14 +264,13 @@ namespace FlaxEngine
|
||||
int index;
|
||||
int MaxChecks = 10000;
|
||||
string result;
|
||||
string reversed = name.Reverse();
|
||||
|
||||
// Find '<name><num>' case
|
||||
var match = IncNameRegex1.Match(reversed);
|
||||
var match = IncNameRegex1.Match(name);
|
||||
if (match.Success && match.Groups.Count == 2)
|
||||
{
|
||||
// Get result
|
||||
string num = match.Groups[0].Value.Reverse();
|
||||
string num = match.Groups[0].Value;
|
||||
|
||||
// Parse value
|
||||
if (int.TryParse(num, out index))
|
||||
@@ -294,12 +293,12 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
// Find '<name> (<num>)' case
|
||||
match = IncNameRegex2.Match(reversed);
|
||||
match = IncNameRegex2.Match(name);
|
||||
if (match.Success && match.Groups.Count == 2)
|
||||
{
|
||||
// Get result
|
||||
string num = match.Groups[0].Value;
|
||||
num = num.Substring(1, num.Length - 2).Reverse();
|
||||
num = num.Substring(1, num.Length - 2);
|
||||
|
||||
// Parse value
|
||||
if (int.TryParse(num, out index))
|
||||
|
||||
Reference in New Issue
Block a user