Last active
December 17, 2020 12:06
-
-
Save SiarheiPilat/5cbd36036de83891ad0894209b585c8c to your computer and use it in GitHub Desktop.
Displays active scene name in top left corner of the 'Scene' window, also highlights that scene in the 'Project' window, if pressed.
This file contains 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
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEngine; | |
using UnityEditor.SceneManagement; | |
[InitializeOnLoad] | |
public class SceneNameDisplay | |
{ | |
[MenuItem("Tools/Scene name toggle &r")] | |
private static void OpenPopupHierarchy() | |
{ | |
EditorPrefs.SetBool("ShowSceneDisplay", !EditorPrefs.GetBool("ShowSceneDisplay")); | |
SceneView.RepaintAll(); | |
} | |
static SceneNameDisplay() | |
{ | |
EditorPrefs.SetBool("ShowSceneDisplay", true); | |
SceneView.duringSceneGui += OnScene; | |
} | |
static void OnScene(SceneView sceneView) | |
{ | |
if(EditorPrefs.GetBool("ShowSceneDisplay")) | |
{ | |
Handles.BeginGUI(); | |
GUILayout.BeginArea(new Rect(0, 0, 250, 20)); | |
Rect rect = EditorGUILayout.BeginVertical(); | |
GUI.color = new Color(1.0f, 1.0f, 1.0f, 0.5f); | |
GUI.Box(rect, GUIContent.none); | |
GUILayout.FlexibleSpace(); | |
if(GUILayout.Button(EditorSceneManager.GetActiveScene().name, GUIStyle.none)) | |
{ | |
EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath<SceneAsset>(EditorSceneManager.GetActiveScene().path).GetInstanceID()); | |
} | |
GUILayout.FlexibleSpace(); | |
EditorGUILayout.EndVertical(); | |
GUILayout.EndArea(); | |
Handles.EndGUI(); | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment