Created
July 8, 2019 20:19
-
-
Save ErnSur/ad4f5c70478b3309c33d84ea14ab58a3 to your computer and use it in GitHub Desktop.
Unity UI-Elements Scope implementation
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
namespace UnityEngine.UIElements | |
{ | |
public class Scope : IDisposable | |
{ | |
public static VisualElement CurrentRoot { get; private set; } | |
public readonly VisualElement root; | |
private VisualElement _previousRoot; | |
public Scope(VisualElement root) | |
{ | |
if (CurrentRoot != null) | |
{ | |
_previousRoot = CurrentRoot; | |
_previousRoot.Add(root); | |
} | |
CurrentRoot = this.root = root; | |
} | |
public Scope(VisualElement root, string name) : this(root) | |
{ | |
root.name = name; | |
} | |
void IDisposable.Dispose() | |
{ | |
CurrentRoot = _previousRoot; | |
} | |
public void Add(VisualElement child) | |
{ | |
root.Add(child); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment