Control "Layers" dropdown from UnityEditor script

The editor’s got a dropdown marked Layers in the top right, that controls which layers are rendered in the SceneView. Is there a way to access this from a script?

(I’m aware that I can change the render layers of a camera, but this only affects the Game view - I want to hide/show layers in the Scene view).

Also, is there a way to have this property only affect a single SceneView, so that I could have several SceneView windows showing different layer configurations of the same area simultaneously?

1 Answer

1

//SceneView只看UI层
Tools.visibleLayers = LayerMask.GetMask(“UI”);
//还原SceneView看EveryThing
Tools.visibleLayers = -1;