Skip to content

Instantly share code, notes, and snippets.

@shanecelis
Created November 21, 2021 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shanecelis/a0e5865fb74eeb656775d0323efe5a67 to your computer and use it in GitHub Desktop.
Save shanecelis/a0e5865fb74eeb656775d0323efe5a67 to your computer and use it in GitHub Desktop.
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