Outline text method

This commit is contained in:
ang-xd committed 2025-03-01 15:30:14 -05:00
1 parent 26afd47d2a
commit d9081ed17b
2 files changed
+21 -1

No files matched your search

@@ -19,7 +19,7 @@ public class TeleportButton : CustomActionButton
public override int MaxUses => 2;
public override LoadableAsset<Sprite> Sprite => ExampleAssets.TeleportButton;
public override Color TextOutlineColor => new Color32(221, 176, 152, 255);
public static bool IsZoom { get; private set; }
public override bool Enabled(RoleBehaviour? role)
+20
View File
@@ -46,6 +46,11 @@ public abstract class CustomActionButton
/// </summary>
public virtual int MaxUses => 0;
/// <summary>
/// Gets the button's text outline color.
/// </summary>
public virtual Color TextOutlineColor => Color.clear;
/// <summary>
/// Gets the location of the button on the screen.
/// </summary>
@@ -114,6 +119,11 @@ public abstract class CustomActionButton
Button.SetInfiniteUses();
}
if (TextOutlineColor != Color.clear)
{
SetTextOutline(TextOutlineColor);
}
var pb = Button.GetComponent<PassiveButton>();
pb.OnClick = new Button.ButtonClickedEvent();
pb.OnClick.AddListener((UnityAction)(() =>
@@ -207,6 +217,16 @@ public abstract class CustomActionButton
EffectActive = false;
}
/// <summary>
/// A utility function to change the outline color of the button's text.
/// </summary>
/// <param name="color">The new color.</param>
/// <param name="thickness">The thickness of the outline. Set to 0 if you want to remove it.</param>
public virtual void SetTextOutline(Color color)
{
Button?.buttonLabelText.SetOutlineColor(color);
}
/// <summary>
/// A utility function to override the sprite of the button.
/// </summary>