Add ButtonAttribute to display methods in editor properties panel

#1917
This commit is contained in:
Wojtek Figat
2024-12-06 16:10:50 +01:00
parent 1088a71e69
commit b6d2a3683c
8 changed files with 122 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
using System;
namespace FlaxEngine
{
/// <summary>
/// Displays the method in the properties panel where user can click and invoke this method.
/// </summary>
/// <remarks>Supported on both static and member methods that are parameterless.</remarks>
[AttributeUsage(AttributeTargets.Method)]
public sealed class ButtonAttribute : Attribute
{
/// <summary>
/// The button text. Empty value will use method name (auto-formatted).
/// </summary>
public string Text;
/// <summary>
/// The button tooltip text. Empty value will use method documentation.
/// </summary>
public string Tooltip;
/// <summary>
/// Initializes a new instance of the <see cref="ButtonAttribute"/> class.
/// </summary>
public ButtonAttribute()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ButtonAttribute"/> class.
/// </summary>
/// <param name="text">The button text.</param>
/// <param name="tooltip">The button tooltip.</param>
public ButtonAttribute(string text, string tooltip = null)
{
Text = text;
Tooltip = tooltip;
}
}
}