ParagonUIBehaviour

Abstract base class for all Paragon UI MonoBehaviours. Extends ParagonBehaviour with a cached RectTransform reference and [ExecuteAlways] attribute for edit-mode support. Requires a RectTransform component on the GameObject.

Definition

Namespace: Paragon Assembly: Paragon.dll

[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
public abstract class ParagonUIBehaviour : ParagonBehaviour

Inheritance: SerializedMonoBehaviourParagonBehaviour → ParagonUIBehaviour Attributes:

  • [ExecuteAlways] — Runs in both play mode and edit mode

  • [RequireComponent(typeof(RectTransform))] — Guarantees a RectTransform is present

Remarks

ParagonUIBehaviour provides a minimal UI-specific base class with two additions over ParagonBehaviour:

  1. [ExecuteAlways] — Ensures the behaviour's lifecycle methods (OnEnable, OnDisable, Update, etc.) run in the Unity Editor outside of play mode. This is essential for UI components that need to update their layout or appearance during editor workflows.

  2. Cached RectTransform — The rectTransform field provides quick access to the GameObject's RectTransform component. It is lazily initialized on first access via the RectSize property.

Debug Property

The RectSize property is shown in the Inspector only when DebugEnabled is true (via [ShowIf("DebugEnabled")]). It returns the RectTransform.rect.size, providing a quick read of the element's pixel dimensions.

Quick Lookup

Goal
How

Create a UI behaviour

Subclass ParagonUIBehaviour

Get rect size

behaviour.RectSize (debug only in Inspector)

Access RectTransform

rectTransform (protected field)

Runs in edit mode

Yes — [ExecuteAlways]

Properties

RectSize

Returns the pixel size of the RectTransform. Lazily initializes the rectTransform field if not yet cached. Shown in Inspector only when debug mode is enabled.

Fields

Field
Type
Access
Description

rectTransform

RectTransform

protected

Cached reference to the RectTransform component (lazily initialized)

Extension Points

Optional Overrides

All virtual methods from ParagonBehaviour remain available:

Method
Purpose

OnEnable()

Called when enabled — runs in edit mode too due to [ExecuteAlways]

OnDisable()

Called when disabled

OnDebug()

Custom debug rendering

Implementation Requirements

When subclassing ParagonUIBehaviour, you MUST:

  1. Place the component on a GameObject with a RectTransform (guaranteed by [RequireComponent])

  2. Be aware that lifecycle methods run in edit mode due to [ExecuteAlways]

You SHOULD:

  • Guard play-mode-only logic with Application.isPlaying checks

  • Use the rectTransform field instead of GetComponent<RectTransform>() for performance

Common Pitfalls

circle-exclamation
circle-exclamation

Examples

Basic UI Element

See Also

Last updated