Last active
February 9, 2024 09:07
-
-
Save supertask/78ddff255a9492e6ddfbfbac1b971cfe to your computer and use it in GitHub Desktop.
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
public static class RosettaUiToolkitExtension | |
{ | |
private static readonly List<Action> _afterBuildActions = new(); | |
public static void Clear() | |
{ | |
_afterBuildActions.Clear(); | |
} | |
public static void Apply() | |
{ | |
foreach (var action in _afterBuildActions) | |
{ | |
action(); | |
} | |
Clear(); | |
} | |
public static Element SetTextWrap(this Element element, bool isWrap) | |
{ | |
_afterBuildActions.Add(() => | |
{ | |
var ve = UIToolkitBuilder.Instance.GetUIObj(element); | |
ve.style.whiteSpace = isWrap ? WhiteSpace.Normal : WhiteSpace.NoWrap; | |
}); | |
return element; | |
} | |
} | |
void Start() { | |
RosettaUiToolkitExtension.Apply(); | |
} | |
void CreateElement() { | |
//... | |
UI.Label(() => $"file path: {PrefsGUI.Kvs.PrefsKvsPathSelector.path}").SetTextWrap(true).SetWidth(500), | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment