← Back to all addons

Scene Selector Overlay

Posted by Gyvr on May 9, 2024 at 10:03 PM

FeatureEditor1.4 Verified
💡 3

This editor script adds a popup menu to the scene view to navigate between scenes. This could be useful when designing different maps without having to use the asset browser every time you need to switch from one map to another.

Add this script anywhere (ideally in an Editor assembly) SceneSelectorOverlay.cs:

using UnityEditor;
using UnityEditor.Overlays;
using UnityEngine.UIElements;
using System.Linq;
using UnityEditor.SceneManagement;

namespace Gyvr.Mythril2D
{
    [Overlay(typeof(SceneView), "Mythril2D Scene Selector", true)]
    public class SceneSelectorOverlay : Overlay
    {
        public override VisualElement CreatePanelContent()
        {
            var root = new VisualElement() { };

            string[] guids = AssetDatabase.FindAssets("t:scene", null);
            var scenes = guids.Select(guid => AssetDatabase.GUIDToAssetPath(guid)).ToArray();

            foreach (var scene in scenes)
            {
                var button = new Button() { text = scene.Split('/').Last() };
                button.clicked += () => EditorSceneManager.OpenScene(scene);
                root.Add(button);
            }

            return root;
        }
    }
}

Usage:

  1. Open the scene view
  2. Click anywhere inside the view
  3. Press [SPACE]
  4. Enable “Mythril2D Scene Selector”
  5. Enjoy!

💬 Comments (3)

FTLJustin May 09, 2024 at 10:10 PM
Very handy!
Gyvr May 09, 2024 at 10:11 PM
Thank you! I think level designers are gonna love this one
🔥 1
VIIЯLΞSS May 09, 2024 at 10:18 PM
Very handy for me that way I don’t need to constantly search for a scene
👌 1

Want to continue the conversation?