44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
|
|
public class BulkRenamer : EditorWindow
|
|
{
|
|
private int fixedRow = 1; // Row to use for all names
|
|
private int fixedLayer = 1; // Layer to use for all names
|
|
private int startingColumn = 1; // Starting column number
|
|
|
|
[MenuItem("Tools/Bulk Renamer")]
|
|
public static void ShowWindow()
|
|
{
|
|
GetWindow<BulkRenamer>("Bulk Renamer");
|
|
}
|
|
|
|
void OnGUI()
|
|
{
|
|
GUILayout.Label("Bulk Renamer Settings", EditorStyles.boldLabel);
|
|
fixedRow = EditorGUILayout.IntField("Fixed Row", fixedRow);
|
|
startingColumn = EditorGUILayout.IntField("Starting Column", startingColumn);
|
|
fixedLayer = EditorGUILayout.IntField("Fixed Layer", fixedLayer);
|
|
|
|
if (GUILayout.Button("Rename Selected Objects"))
|
|
{
|
|
RenameObjects();
|
|
}
|
|
}
|
|
|
|
void RenameObjects()
|
|
{
|
|
if (Selection.gameObjects.Length == 0)
|
|
{
|
|
EditorUtility.DisplayDialog("No objects selected", "Please select at least one object in the scene.", "OK");
|
|
return;
|
|
}
|
|
|
|
int currentColumn = startingColumn;
|
|
foreach (GameObject obj in Selection.gameObjects)
|
|
{
|
|
obj.name = $"{fixedRow}-{currentColumn}-{fixedLayer}";
|
|
currentColumn++; // Only increment column
|
|
}
|
|
}
|
|
} |