Skip to content

Instantly share code, notes, and snippets.

Last active Jan 11, 2020
What would you like to do?
Quickly toggle the visibility of UI layer (canvases) in Unity's Scene view
using UnityEditor;
using UnityEngine;
public class UIToggler
private const int UI_LAYER = 1 << 5;
private static void Init()
#if UNITY_2019_1_OR_NEWER
SceneView.duringSceneGui -= OnSceneGUI;
SceneView.duringSceneGui += OnSceneGUI;
SceneView.onSceneGUIDelegate -= OnSceneGUI;
SceneView.onSceneGUIDelegate += OnSceneGUI;
private static void OnSceneGUI( SceneView sceneView )
bool uiVisible = ( Tools.visibleLayers & UI_LAYER ) == UI_LAYER;
if( GUI.Button( new Rect( 0f, 0f, 125f, 25f ), uiVisible ? "Hide Canvas" : "Show Canvas" ) )
if( uiVisible )
Tools.visibleLayers &= ~UI_LAYER;
Tools.visibleLayers |= UI_LAYER;
Copy link

How To

Simply create a folder called Editor inside your Project window and add this script inside it. Then, click the small button at the top left corner of the Scene view to toggle the UI objects' visibility in Scene view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment