Skip to content

Commit 239c128

Browse files
committed
increment the last number in the GameObject name
1 parent 6b4c8b7 commit 239c128

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ private static string IncrementFileName(string path, string filename)
170170
string ext = Path.GetExtension (filename);
171171

172172
int index = 1;
173+
174+
// try extracting the current index from the name and incrementing it
175+
var result = System.Text.RegularExpressions.Regex.Match(fileWithoutExt, @"\d+$");
176+
if (result != null) {
177+
var number = result.Value;
178+
if (int.TryParse (number, out index)) {
179+
fileWithoutExt = fileWithoutExt.Remove (fileWithoutExt.LastIndexOf (number));
180+
index++;
181+
}
182+
}
183+
173184
string file = null;
174185
do {
175186
file = string.Format ("{0} {1}{2}", fileWithoutExt, index, ext);

0 commit comments

Comments
 (0)