Created
June 19, 2022 16:27
-
-
Save hogashi/1d71bb2cdf34e7ab717c4fe8e49a2aa7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
public class EditorWindowSample : EditorWindow | |
{ | |
[MenuItem("Editor/Sample")] | |
private static void Create() | |
{ | |
GetWindow<EditorWindowSample>("rename samplescene"); | |
} | |
private void RenameActiveScene() | |
{ | |
int sceneCount = UnityEngine.SceneManagement.SceneManager.sceneCount; | |
for (int i = 0; i < sceneCount; i += 1) { | |
UnityEngine.SceneManagement.Scene scene = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i); | |
if (scene.name == "Sample Scene") { | |
var path = scene.path; | |
var guid = AssetDatabase.AssetPathToGUID(path); | |
var newName = scene.name + "_" + guid; | |
Debug.Log("Renaming scene \"" + path + "\" to \"" + newName + "\""); | |
var err = AssetDatabase.RenameAsset(path, newName); | |
if (err != "") { | |
Debug.LogError(err); | |
} | |
} | |
} | |
} | |
private void OnGUI() | |
{ | |
using (new GUILayout.HorizontalScope()) | |
{ | |
if (GUILayout.Button("rename")) | |
{ | |
RenameActiveScene(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment