RegionDisplayNameAction - jimdroberts/FishMMO GitHub Wiki
RegionDisplayNameAction is a region action ScriptableObject for FishMMO that displays a 2D label with the region's name and custom styling when triggered. It allows for dynamic, styled notifications to the player, enhancing immersion and providing clear feedback when entering or interacting with regions.
-
public static event Action<string, FontStyle, Font, int, Color, float, bool, bool, Vector2> OnDisplay2DLabel
Event invoked to display a 2D label with custom styling and position.
-
public Color DisplayColor
The color of the displayed label text.
-
public FontStyle Style
The font style of the label text.
-
public Font Font
The font used for the label text.
-
public int FontSize
The size of the label font.
-
public float LifeTime
The lifetime (in seconds) for which the label is displayed.
-
public bool FadeColor
If true, the label color will fade out over its lifetime.
-
public bool IncreaseY
If true, the label will increase its Y position (move upward) over time.
-
public override void Invoke(IPlayerCharacter character, Region region, bool isReconciling)
Displays a styled 2D label with the region's name for the owning client. Parameters: - IPlayerCharacter character: The player character triggering the action. - Region region: The region whose name will be displayed. - bool isReconciling: Indicates if the action is part of a reconciliation process. Returns: void. No exceptions are thrown.
- Create a new RegionDisplayNameAction ScriptableObject via the Unity Editor (Assets > Create > FishMMO > Region > Region Display Name).
- Configure the DisplayColor, Style, Font, FontSize, LifeTime, FadeColor, and IncreaseY fields in the inspector as desired.
- Attach the RegionDisplayNameAction to a region definition or trigger as appropriate.
// Example 1: Assigning a display name action to a region
// 1. Create a new RegionDisplayNameAction asset in the Unity Editor.
// 2. Configure the display settings in the inspector.
// 3. Reference this asset in your region setup.
// Example 2: Triggering the action in code
// This is typically handled by the region system, but can be invoked manually for testing.
regionDisplayNameAction.Invoke(playerCharacter, region, false);
- Ensure all display fields are set to achieve the desired visual effect.
- Use FadeColor and IncreaseY to create more dynamic and visually appealing notifications.
- Avoid displaying labels during reconciliation or for non-owning clients to prevent duplicate or unintended displays.