Class Button
Assembly: PopcorningGuineaPig.Engine.dll
public class Button : InteractiveUIElement, IUIElement
Constructors
|
Edit this page
View Source
Button(Texture2D, Vector2, Vector2, Rectangle[], Font?)
Declaration
public Button(Texture2D texture, Vector2 position, Vector2 size, Rectangle[] nineSliceRects, Font? font = null)
Parameters
| Type |
Name |
Description |
| Texture2D |
texture |
|
| Vector2 |
position |
|
| Vector2 |
size |
|
| Rectangle[] |
nineSliceRects |
|
| Font? |
font |
|
|
Edit this page
View Source
Button(Texture2D, Vector2, Vector2, Font?)
Declaration
public Button(Texture2D texture, Vector2 position, Vector2 size, Font? font = null)
Parameters
| Type |
Name |
Description |
| Texture2D |
texture |
|
| Vector2 |
position |
|
| Vector2 |
size |
|
| Font? |
font |
|
|
Edit this page
View Source
Declaration
public Button(string text, Vector2 position, Vector2 size, Color color, Font? font = null)
Parameters
Properties
|
Edit this page
View Source
Declaration
public Color Color { get; set; }
Property Value
|
Edit this page
View Source
Forced hover from gamepad focus navigation.
Declaration
public bool FocusHighlight { get; set; }
Property Value
|
Edit this page
View Source
Declaration
public int FontSize { get; set; }
Property Value
|
Edit this page
View Source
Text
Declaration
public string Text { get; set; }
Property Value
|
Edit this page
View Source
TextColor
Declaration
public Color TextColor { get; set; }
Property Value
Methods
|
Edit this page
View Source
CreateNineSliceRects(Texture2D, int)
Declaration
public static Rectangle[] CreateNineSliceRects(Texture2D texture, int cornerSize)
Parameters
| Type |
Name |
Description |
| Texture2D |
texture |
|
| int |
cornerSize |
|
Returns
| Type |
Description |
| Rectangle[] |
|
|
Edit this page
View Source
Override DrawSelf to handle label drawing
Derived classes should call base.DrawSelf() to ensure labels are drawn
Declaration
protected override void DrawSelf()
Overrides
|
Edit this page
View Source
Fire the click action (gamepad focus confirm).
Declaration
public void InvokeClick()
|
Edit this page
View Source
Declaration
public void SetClickSound(IAudioSource sound)
Parameters
| Type |
Name |
Description |
| IAudioSource |
sound |
|
|
Edit this page
View Source
Declaration
public void SetColors(Color normal, Color hover, Color pressed)
Parameters
| Type |
Name |
Description |
| Color |
normal |
|
| Color |
hover |
|
| Color |
pressed |
|
|
Edit this page
View Source
Declaration
public void SetFont(Font font)
Parameters
| Type |
Name |
Description |
| Font |
font |
|
|
Edit this page
View Source
Declaration
public void SetHoverSound(IAudioSource sound)
Parameters
| Type |
Name |
Description |
| IAudioSource |
sound |
|
|
Edit this page
View Source
Sets the localization key for automatic text updates when language changes.
Declaration
public void SetLocalizationKey(string localizationKey, string? fallbackText = null)
Parameters
| Type |
Name |
Description |
| string |
localizationKey |
The localization key (e.g., "TUTORIAL")
|
| string |
fallbackText |
Text to use if translation fails
|
|
Edit this page
View Source
Sets the localization service to use for automatic font and text management.
Declaration
public override void SetLocalizationService(ILocalizationService? localizationService)
Parameters
Overrides
|
Edit this page
View Source
Declaration
public void SetOnClick(Action action)
Parameters
| Type |
Name |
Description |
| Action |
action |
|
|
Edit this page
View Source
Declaration
public void SetPosition(Vector2 position)
Parameters
| Type |
Name |
Description |
| Vector2 |
position |
|
|
Edit this page
View Source
Declaration
public void SetSize(Vector2 size)
Parameters
|
Edit this page
View Source
SetText(string)
Declaration
public void SetText(string text)
Parameters
| Type |
Name |
Description |
| string |
text |
|
|
Edit this page
View Source
SetTextProperties(int, Color)
Declaration
public void SetTextProperties(int fontSize, Color textColor)
Parameters
| Type |
Name |
Description |
| int |
fontSize |
|
| Color |
textColor |
|
|
Edit this page
View Source
SetTexture(Texture2D, Rectangle[]?)
Attach (or replace) a background texture after construction. Pass nine-slice
rectangles (exactly 9, e.g. from CreateNineSliceRects(Texture2D, int)) to draw
as a nine-patch; pass null to draw the texture stretched.
Declaration
public void SetTexture(Texture2D texture, Rectangle[]? nineSliceRects = null)
Parameters
| Type |
Name |
Description |
| Texture2D |
texture |
|
| Rectangle[] |
nineSliceRects |
|
|
Edit this page
View Source
Override UpdateSelf to provide common interactive element functionality
Derived classes should call base.UpdateSelf() before their own update logic
Declaration
protected override void UpdateSelf()
Overrides
|
Edit this page
View Source
Updates the tooltip text from the localization service using the stored tooltip localization key.
Declaration
protected override void UpdateTooltipFromLocalization()
Overrides
Implements