Created
August 21, 2019 14:26
-
-
Save rob5300/0301807045ea5a0e32d1e2551d884a7a to your computer and use it in GitHub Desktop.
Applies preset layermask on scene open and restores it on scene closed. Made for use in custom ui prefab editing scenes to show the UI layer automatically.
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 UnityEngine; | |
using UnityEditor; | |
/// <summary> | |
/// Applies preset layermask on scene open and restores it on scene closed. | |
/// Made for use in custom ui prefab editing scenes to show the UI layer automatically. | |
/// </summary> | |
[ExecuteInEditMode] | |
public class CanvasEditorHelper : MonoBehaviour | |
{ | |
public LayerMask MaskPreset; | |
private LayerMask oldMask; | |
private void OnEnable() | |
{ | |
oldMask = Tools.visibleLayers; | |
Tools.visibleLayers = MaskPreset; | |
} | |
private void OnDestroy() | |
{ | |
Tools.visibleLayers = oldMask; | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment