# PowerButtons

Fields
Methods

CustomButtons

CreateButton
AddButtonToTab

# Constructors

No constructors

# Fields

# CustomButtons: Dictionary<string, PowerButton>

Dictionary with all custom buttons which made with NCMS


# Methods

# CreateButton(name, sprite, localName, localDescription, position, type = ButtonType.Click, parent = null, call = null): PowerButton

Creates new PowerButton

Parameter Type Optional Description
name string No GameObject name of new button
sprite UnityEngine.Sprite No Button sprite
localName string No Name which will be shown in tooltip
localDescription string No Description which will be shown in tooltip
position UnityEngine.Vector2 No Button position
type NCMS.Utils.ButtonType Yes Type of button you want to create
parent UnityEngine.Transform Yes Parent object to which this button will be attached
call UnityEngine.Events.UnityAction Yes Button on click behaviour

Returns: PowerButton

Example:

//...
var sprite = NCMS.Utils.Sprites.LoadSprite($"{Mod.Info.Path}/icon.png");
var button = NCMS.Utils.PowerButtons.CreateButton("exampleButton", sprite, "Example Button", "This is the example button", Vector2.zero, NCMS.Utils.ButtonType.Click, null, exampleMethod);
//...
static void exampleMethod(){
    Debug.Log("Example Button was clicked");
}

# CreateTextButton(name, text, position, color, position, parent = null, callback = null): UnityEngine.Button

Creates new PowerButton

Parameter Type Optional Description
name string No GameObject name of new button
text string No Text which will be shown on the button
position UnityEngine.Vector2 No Button position
color UnityEngine.Color No Color of button
parent UnityEngine.Transform Yes Parent object to which this button will be attached
callback UnityEngine.Events.UnityAction Yes Button on click behaviour

Returns: UnityEngine.Button


# AddButtonToTab(button, tab, position): void

Attaches PowerButton to PowersTab

Parameter Type Optional Description
button PowerButton No Button, which you want to attach to powers tab
tab NCMS.Utils.PowerTab No PowerTab to which you want to attach PowerButton
position UnityEngine.Vector2 No Button position

Returns: void

Example:

//...
var sprite = NCMS.Utils.Sprites.LoadSprite($"{Mod.Info.Path}/icon.png");
var button = NCMS.Utils.PowerButtons.CreateButton("exampleButton", sprite, "Example Button", "This is the example button", Vector2.zero, NCMS.Utils.ButtonType.Click, null, exampleMethod);
NCMS.Utils.PowerButtons.AddButtonToTab(button, NCMS.Utils.PowerTab.Main, new Vector2(332, -18));
//...
static void exampleMethod(){
    Debug.Log("Example Button was clicked");
}

Result:


# GetToggleValue(name): bool

Checks current state of button with type Toggle

Parameter Type Optional Description
name string No Name of button which toggle state you want to check

Returns: bool


# ToggleButton(name): void

Changes current state of button with type Toggle

Parameter Type Optional Description
name string No Name of button which toggle state you want to change

Returns: void