ActionVariableCreateMenu

Popup menu that allows users to create new dynamic action variables from the Inspector. Presents a type selector and name input field, validates the input, and adds the variable to the owning ActionVariables container.

Definition

Namespace: Paragon.Core.ActionSystem.Editor Assembly: Paragon.Editor.dll

public class ActionVariableCreateMenu

Remarks

This menu is instantiated by ActionVariablesDrawer and opened when the user clicks the + button in the Variables header. It uses Odin's GenericSelector<Type> to present a list of supported variable types, then collects a variable name via a text field before committing the new variable.

The menu enforces two validation rules before enabling the "Add Variable" button:

  1. Name validity — must match the pattern ^[a-zA-Z_][\w ]*(\.[a-zA-Z_][\w ]*)*$, must not be empty, and must not duplicate an existing variable name.

  2. Type validity — must be one of the supported types listed below.

Quick Lookup

Goal
How

Open the menu

createMenu.Show(buttonRect)

Supported types

int, float, string, bool, Vector2, Vector3, GameObject, Transform, Component, Action

Constructor

public ActionVariableCreateMenu(ActionVariablesDrawer drawer)
Parameter
Type
Description

drawer

ActionVariablesDrawer

The parent drawer whose ActionVariables will receive the new variable

Reads the ActionVariables instance from the drawer's ValueEntry.SmartValue and builds the type selector.

Methods

Show

Opens the popup menu anchored to the given button rect.

Parameter
Type
Description

buttonRect

Rect

The screen-space rect of the button that triggered the menu

Creates an OdinEditorWindow popup containing the type selector and appends the name input field and "Add Variable" button via OnEndGUI.

Supported Variable Types

Display Name
.NET Type

Integer

int

Float

float

String

string

Bool

bool

Vector2

Vector2

Vector3

Vector3

GameObject

GameObject

Transform

Transform

Component

Component

Action

System.Action

Validation Rules

Name Validation

Returns true when all of the following are satisfied:

  • Name is not null or whitespace

  • No existing variable in ActionVariables has the same name (HasVariable check)

  • Name matches regex ^[a-zA-Z_][\w ]*(\.[a-zA-Z_][\w ]*)*$ — must start with a letter or underscore, may contain word characters and spaces, supports dot-separated segments

Type Validation

Returns true when the type is non-null and is one of the supported variable types.

Visual Behavior

The "Add Variable" button changes color to indicate state:

State
Button Color

No name or type selected

Gray (disabled)

Valid name and type

Green (enabled)

Invalid name or type conflict

Red (disabled)

Common Pitfalls

circle-exclamation
circle-exclamation

See Also

Last updated