PowerQuest 0.20.6
Loading...
Searching...
No Matches
IButton Interface Reference

Detailed Description

Gui Button- Buttons are a bit like your room's props, but they have a few more states so they can animate when clicked.

    Button.KeypadEnter.Clickable = false;
    Button.AnimHover = "FlashRed";
    Button.ColorPress = Color.yellow;
    Button.Text = "Let's do it";
    Button.Description = "This button wins the game";

Inherits IGuiControl.

Properties

new string Description [get, set]
 Gets/Sets the description text shown to players when they hover the mouse over the control.
 
new string Cursor [get, set]
 Gets or sets the cursor to show when hovering over the control. If empty, default active cursor will be used.
 
new string Text [get, set]
 Gets/Sets the text in the button (if it has any)
 
new string Anim [get, set]
 Gets/Sets the default Sprite (or animation)
 
string AnimHover [get, set]
 Gets/Sets the Sprite (or animation) shown when the button is selected/hovered.
 
string AnimClick [get, set]
 Gets/Sets the Sprite (or animation) shown when the button is pressed.
 
string AnimOff [get, set]
 Gets/Sets the Sprite (or animation) shown when the button is disabled (when Clickable = false)
 
new Color Color [get, set]
 Gets/Sets the color for the control.
 
Color ColorHover [get, set]
 Gets/Sets the color for the control when the button is selected/hovered over.
 
Color ColorClick [get, set]
 Gets/Sets the color for the control when the buttons is clicked.
 
Color ColorOff [get, set]
 Gets/Sets the color for the control when the button is disabled (when Clickable = false)
 
bool Clickable [get, set]
 Gets or Sets whether clicking on the object triggers an event.
 
bool Animating [get]
 Whether an animation triggered by PlayAnimation() is currently playing. Note- this does not include animations set using the Anim property.
 
float Alpha [get, set]
 Gets/Sets the transparency of the sprite. (0.0f being fully transparent, 1.0f being fully opaque.)
 
- Properties inherited from IGuiControl
MonoBehaviour Instance [get]
 Access to the actual game object component in the scene. Note that controls themselves can be cast to their component type if known.
 
bool Visible [get, set]
 Sets the control visible invisible the control.
 
Vector2 Position [get, set]
 Gets/Sets the position of the control. Note that this will be overridden if using AlignTo or FitTo component.
 
bool Focused [get]
 Gets/Sets whether this control is focused (ie: the mouse is hovering over it, or it's selected with keyboard)
 
bool HasKeyboardFocus [get, set]
 Gets/Sets whether this control has the current keyboard focus (can also be used for specifying which control has 'controller' focus)
 

Public Member Functions

void PauseAnimation ()
 Pauses the currently playing animation. Only works for animations played with PlayAnimationBG()
 
void ResumeAnimation ()
 Resumes playing the current animation after PauseAnimation() was called.
 
void StopAnimation ()
 Stops the current animation- returns to Idle animation. Only works for animations played with PlayAnimationBG()
 
Coroutine PlayAnimation (string animName)
 Plays an animation on the control. Will block the script until complete.
 
void PlayAnimationBG (string animName)
 Play an animation on the control without halting the script. Will return to idle after animation ends, unless pauseAtEnd is true.
 
void AddAnimationTrigger (string triggerName, bool removeAfterTriggering, System.Action action)
 Adds a function to be called on an animation event here. Eg: to play a sound or effect on an animation tag.
 
void RemoveAnimationTrigger (string triggerName)
 Removes an existing animation trigger.
 
Coroutine WaitForAnimTrigger (string triggerName)
 Waits until an Event/Tag in the current animation is reached.
 
Coroutine Fade (float start, float end, float duration, eEaseCurve curve=eEaseCurve.Smooth)
 Fade the sprite's alpha. (0.0f being fully transparent, 1.0f being fully opaque.)
 
void FadeBG (float start, float end, float duration, eEaseCurve curve=eEaseCurve.InOutSmooth)
 Fade the sprite's alpha (non-blocking). (0.0f being fully transparent, 1.0f being fully opaque.)
 
- Public Member Functions inherited from IGuiControl
void Show ()
 Shows the control.
 
void Hide ()
 Hides the control.
 
void SetPosition (float x, float y)
 Sets the position of the control. Note that this will be overridden if using AlignTo or FitTo component.
 
GuiControl DuplicateControl (string name=null, IGuiControl parent=null)
 Duplicates the control. Useful for adding elements dynamically to a gui. You can optionally specify a new name for the control, and a parent object (such as a grid container)
 

Property Documentation

◆ Description

new string Description
getset

Gets/Sets the description text shown to players when they hover the mouse over the control.

Implements IGuiControl.

◆ Cursor

new string Cursor
getset

Gets or sets the cursor to show when hovering over the control. If empty, default active cursor will be used.

Implements IGuiControl.

◆ Text

new string Text
getset

Gets/Sets the text in the button (if it has any)

Implements IGuiControl.

◆ Anim

new string Anim
getset

Gets/Sets the default Sprite (or animation)

See also
Anim
AnimHover
AnimClick
AnimOff

Implements IGuiControl.

◆ AnimHover

string AnimHover
getset

Gets/Sets the Sprite (or animation) shown when the button is selected/hovered.

See also
Anim
AnimHover
AnimClick
AnimOff

◆ AnimClick

string AnimClick
getset

Gets/Sets the Sprite (or animation) shown when the button is pressed.

See also
Anim
AnimHover
AnimClick
AnimOff

◆ AnimOff

string AnimOff
getset

Gets/Sets the Sprite (or animation) shown when the button is disabled (when Clickable = false)

See also
Anim
AnimHover
AnimClick
AnimOff
Clicable

◆ Color

new Color Color
getset

Gets/Sets the color for the control.

Implements IGuiControl.

◆ ColorHover

Color ColorHover
getset

Gets/Sets the color for the control when the button is selected/hovered over.

◆ ColorClick

Color ColorClick
getset

Gets/Sets the color for the control when the buttons is clicked.

◆ ColorOff

Color ColorOff
getset

Gets/Sets the color for the control when the button is disabled (when Clickable = false)

See also
Clicable

◆ Clickable

bool Clickable
getset

Gets or Sets whether clicking on the object triggers an event.

See also
ColorOff
AnimOff

◆ Animating

bool Animating
get

Whether an animation triggered by PlayAnimation() is currently playing. Note- this does not include animations set using the Anim property.

See also
Anim
PlayAnimation

◆ Alpha

float Alpha
getset

Gets/Sets the transparency of the sprite. (0.0f being fully transparent, 1.0f being fully opaque.)

Member Function Documentation

◆ PauseAnimation()

void PauseAnimation ( )

Pauses the currently playing animation. Only works for animations played with PlayAnimationBG()

See also
PlayAnimationBG()

◆ ResumeAnimation()

void ResumeAnimation ( )

Resumes playing the current animation after PauseAnimation() was called.

See also
PauseAnimation()

◆ StopAnimation()

void StopAnimation ( )

Stops the current animation- returns to Idle animation. Only works for animations played with PlayAnimationBG()

See also
PlayAnimationBG()

◆ PlayAnimation()

Coroutine PlayAnimation ( string animName)

Plays an animation on the control. Will block the script until complete.

After finishing, the control returns to it's default sprite/animation specified by the 'Anim' property. Note, that by default gui Image controls may not have a "Power Sprite Animation" component, and this needs to be added for them to play animations.

See also
Animating
PlayAnimation
PlayAnimationBG
PauseAnimation
StopAnimation
Anim

◆ PlayAnimationBG()

void PlayAnimationBG ( string animName)

Play an animation on the control without halting the script. Will return to idle after animation ends, unless pauseAtEnd is true.

After finishing, the control returns to it's default sprite/animation specified by the 'Anim' property. Note, that by default gui Image controls may not have a "Power Sprite Animation" component, and this needs to be added for them to play animations.

See also
Animating
PlayAnimation
PlayAnimationBG
PauseAnimation
StopAnimation
Anim

◆ AddAnimationTrigger()

void AddAnimationTrigger ( string triggerName,
bool removeAfterTriggering,
System.Action action )

Adds a function to be called on an animation event here. Eg: to play a sound or effect on an animation tag.

Usage: Add an event to the anim called "Trigger" with a string matching the tag you want (eg: "Shoot") Then call C.Player.AddAnimationTrigger( "Shoot", true, ()=>Audio.PlaySound("Gunshot") );

See also
WaitForAnimationTrigger
RemoveAnimationTrigger

◆ RemoveAnimationTrigger()

void RemoveAnimationTrigger ( string triggerName)

Removes an existing animation trigger.

◆ WaitForAnimTrigger()

Coroutine WaitForAnimTrigger ( string triggerName)

Waits until an Event/Tag in the current animation is reached.

Usage:

  • Add an event to an animation, eg: 'Shoot'.
  • Play the animation in the background
  • Call C.Player.WaitForAnimTrigger("Shoot");.
  • The script will pause until that event is hit before continuing

Example: Using it to play a sound and shake the screen at the time in an animation when the player shoots a gun:

C.Dave.PlayAnimationBG("AimAndFireGun");
C.Dave.WaitForAnimTrigger("Shoot");
Audio.Play("Bang");
Camera.Shake();
Barney: Ouch!
See also
AddAnimationTrigger

◆ Fade()

Coroutine Fade ( float start,
float end,
float duration,
eEaseCurve curve = eEaseCurve.Smooth )

Fade the sprite's alpha. (0.0f being fully transparent, 1.0f being fully opaque.)

◆ FadeBG()

void FadeBG ( float start,
float end,
float duration,
eEaseCurve curve = eEaseCurve.InOutSmooth )

Fade the sprite's alpha (non-blocking). (0.0f being fully transparent, 1.0f being fully opaque.)