Improve timeline tracks renaming to use shared utility with proper incrementing
This commit is contained in:
@@ -1288,10 +1288,7 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
public virtual void AddTrack(Track track, bool withUndo = true)
|
public virtual void AddTrack(Track track, bool withUndo = true)
|
||||||
{
|
{
|
||||||
// Ensure name is unique
|
// Ensure name is unique
|
||||||
int idx = 1;
|
track.Name = GetValidTrackName(track.Name);
|
||||||
var name = track.Name;
|
|
||||||
while (!IsTrackNameValid(track.Name))
|
|
||||||
track.Name = string.Format("{0} {1}", name, idx++);
|
|
||||||
|
|
||||||
// Add it to the timeline
|
// Add it to the timeline
|
||||||
_tracks.Add(track);
|
_tracks.Add(track);
|
||||||
@@ -1843,11 +1840,7 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
/// <returns>The track name.</returns>
|
/// <returns>The track name.</returns>
|
||||||
public string GetValidTrackName(string name)
|
public string GetValidTrackName(string name)
|
||||||
{
|
{
|
||||||
string newName = name;
|
return Utilities.Utils.IncrementNameNumber(name, IsTrackNameValid);
|
||||||
int count = 0;
|
|
||||||
while (!IsTrackNameValid(newName))
|
|
||||||
newName = string.Format("{0} {1}", name, count++);
|
|
||||||
return newName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -854,11 +854,9 @@ namespace FlaxEditor.GUI.Timeline
|
|||||||
/// <param name="name">The base name.</param>
|
/// <param name="name">The base name.</param>
|
||||||
public void Rename(string name)
|
public void Rename(string name)
|
||||||
{
|
{
|
||||||
string newName = name;
|
if (_timeline != null)
|
||||||
int count = 0;
|
name = _timeline.GetValidTrackName(name);
|
||||||
while (_timeline != null && !_timeline.IsTrackNameValid(newName))
|
OnRename(name);
|
||||||
newName = string.Format("{0} {1}", name, count++);
|
|
||||||
OnRename(newName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user