Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A style-less Button for Unity's UIToolkit.
using System;
using UnityEngine.Scripting;
using UnityEngine.UIElements;
/** Rather than trying to undo the .unity-button class, we just remove it from
the element to begin with. */
public class RawButton : Button {
public RawButton() : this(null) { }
public RawButton(Action onClick) : base(onClick) {
this.RemoveFromClassList("unity-button");
}
[Preserve]
public new class UxmlFactory : UxmlFactory<RawButton, UxmlTraits> { }
[Preserve]
public new class UxmlTraits : Button.UxmlTraits { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment