Skip to content

Instantly share code, notes, and snippets.

@supertask
Last active February 9, 2024 09:07
Show Gist options
  • Save supertask/78ddff255a9492e6ddfbfbac1b971cfe to your computer and use it in GitHub Desktop.
Save supertask/78ddff255a9492e6ddfbfbac1b971cfe to your computer and use it in GitHub Desktop.
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