Freyja Button Prompts

Freyja Button Prompts are visual indicators that guide players on which buttons to press for specific actions (e.g., "Press A to Jump" or "Press E to Interact").

Requirements

  • Unity 2021.3.22.f1 or later

  • Odin Inspector 3.1.14.3

Dependencies

Name
Tags

com.freyja.input-system

1.0.0

com.freyja.data-asset

1.0.0

com.freyja.logger

1.0.0

com.unity.textmeshpro

3.0.9

Installation

  1. Install from Unity Package Manager -> (Window -> Package Manager -> Add package from git URL)

Example Usage

Creating Button Prompt

Step 1: Create Button Prompt Data Asset

Create New Prompt Data
Configure Button Prompt Data Asset
  1. Navigate to the Create Menu in the Unity Editor.

  2. Go to Freyja > UI > Button Prompts.

  3. Select Button Prompt to create a new Button Prompt Data Asset.

  4. Configure the Prompt Data in the Inspector by setting the appropriate fields (e.g.,Prompt Name, Input Device Type, Prompt Icon )

Step 2: Set Up the UI Layout

Set Up UI Layout
  1. Create a New Empty Game Object in your scene

    • Right-click in the Hierarchy and select Create Empty.

  2. Add Required UI Components:

    • Horizontal Layout Group: Ensures the button prompts are aligned horizontally.

      • Set Child Alignment to Middle Center.

      • Adjust Spacing as needed.

    • Content Size Fitter: Automatically resizes the container to fit its children.

      • Set Horizontal Fit and Vertical Fit to Preferred Size

    • Button Prompt Component: Add the custom Button Prompt script to the Game Object.

Step 3 : Assign Button Prompt Data Asset

  1. In the Inspector, locate the Button Prompt component.

  2. Drag and drop the Button Prompt Data Asset you created earlier into the Data Asset field'

Step 4: Verify Result

  1. The UI should now display the button prompts based on the configured data asset.

Create Button Prompt Text

Step 1: Set Up Text Mesh Pro

  1. Install Text Mesh Pro (if not already installed)

Step 2: Create Button Prompt Data Asset

Configure Button Prompt Text Data Asset
  1. Navigate to the Create Menu in the Unity Editor.

  2. Go to Freyja > UI > Button Prompts.

  3. Select Button Prompt Text to create a new Button Prompt Text Data Asset.

  4. Configure the Prompt Data in the Inspector by setting the appropriate fields

Step 3: Set Up the UI for Button Prompt Text

  1. Create a New Empty Game Object in your scene

    • Right-click in the Hierarchy and select Create Empty.

  2. Add the Button Prompt Text component to this Game Object.

  3. Assign the Button Prompt Text Data Asset to the component in the Inspector.

Step 4: Verify and Test

Once the Button Prompt Text component and its associated Button Prompt Data Asset are configured, the button prompt text should appear in the scene, displaying the assigned text and icons. To dynamically display specific prompts, you can use the <prompt="<prompt_name>"> tag in your text, where prompt_name references a prompt defined in the Button Prompt Data Asset.

How to Use <prompt> Tag

  1. Reference Prompts in Text:

    1. In the text field of your Button Prompt Text component, use the <prompt="<prompt_name>"> tag to reference a specific prompt defined in the Button Prompt Data Asset.

    2. For example:

      Press <prompt="Jump"> to jump and <prompt="Attack"> to attack.
    3. Jump and Attack are prompt_name values that correspond to entries in the Button Prompt Data Asset.

  2. Ensure Prompt Names Match:

    • The prompt_name used in the <prompt> tag must exactly match the name of a prompt defined in the Button Prompt Data Asset. This ensures the correct icon or text is displayed.

Last updated