Alchemy icon indicating copy to clipboard operation
Alchemy copied to clipboard

Button improvements

Open Petethegoat opened this issue 11 months ago • 2 comments

Pretty prints method name with ObjectNames.NicifyVariableName(), and adds the method signature as a tooltip: image

[Button]
void reticulateSplines() {
	Debug.Log("Reticulating splines...");
}

Allows displaying a button with parameters as a simple button instead: image This will use default parameters when those are specified in the method signature.

[Button(useParameters: false)]
void PerformAction(string ignorableParam, int number = 100) {
	Debug.Log($"{number} {ignorableParam}s.");
}

Also fills default parameters when specified, for the normal invocation foldout: image

[Button]
void MoreMethod(int numberOfFoos = 50) {
	Debug.Log($"FooAmount: {numberOfFoos}");
}

Some other areas I'd like to improve and may get to:

  • Selecting different size buttons (increase button height and font size)
  • Making the placement of buttons in the inspector more intuitive - they currently will always display before any TabGroup or FoldoutGroup fields, which usually feels weird. Trying to put them inside those groups will also affect the layout unpredictably. See #80

I haven't tested this extremely thoroughly yet, and obviously there should be a documentation update alongside these changes.

Petethegoat avatar Mar 26 '24 20:03 Petethegoat