using UnityEngine;
namespace EditorAttributes
{
///
/// Attribute to add a button in the inspector in place of a field
///
public class ButtonFieldAttribute : PropertyAttribute, IRepetableButton
{
public string FunctionName { get; private set; }
public string ButtonLabel { get; private set; }
public float ButtonHeight { get; private set; }
public bool IsRepetable { get; private set; }
public long PressDelay { get; private set; }
public long RepetitionInterval { get; private set; }
///
/// Attribute to add a button in the inspector in place of a field
///
/// The name of the function to call
/// The label displayed on the button
/// The height of the button in pixels
public ButtonFieldAttribute(string functionName, string buttonLabel = "", float buttonHeight = 18f)
{
FunctionName = functionName;
ButtonLabel = buttonLabel;
ButtonHeight = buttonHeight;
}
///
/// Attribute to add a button next to a property
///
/// The name of the function the button activates
/// Makes the button repeat logic on hold
/// How many milliseconds to wait before the logic is executed on hold
/// The interval in milliseconds the logic will repeat
/// The label displayed on the button
/// The height of the button in pixels
public ButtonFieldAttribute(string functionName, bool isRepetable, long pressDelay = 60, long repetitionInterval = 100, string buttonLabel = "", float buttonHeight = 18f)
{
FunctionName = functionName;
ButtonLabel = buttonLabel;
ButtonHeight = buttonHeight;
IsRepetable = isRepetable;
PressDelay = pressDelay;
RepetitionInterval = repetitionInterval;
}
}
}