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 : ParagonBehaviourInheritance: SerializedMonoBehaviour → ParagonBehaviour → ParagonUIBehaviour Attributes:
[ExecuteAlways]— Runs in both play mode and edit mode[RequireComponent(typeof(RectTransform))]— Guarantees aRectTransformis present
Remarks
ParagonUIBehaviour provides a minimal UI-specific base class with two additions over ParagonBehaviour:
[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.Cached
RectTransform— TherectTransformfield provides quick access to the GameObject'sRectTransformcomponent. It is lazily initialized on first access via theRectSizeproperty.
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
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
rectTransform
RectTransform
protected
Cached reference to the RectTransform component (lazily initialized)
Extension Points
Optional Overrides
All virtual methods from ParagonBehaviour remain available:
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:
Place the component on a
GameObjectwith aRectTransform(guaranteed by[RequireComponent])Be aware that lifecycle methods run in edit mode due to
[ExecuteAlways]
You SHOULD:
Guard play-mode-only logic with
Application.isPlayingchecksUse the
rectTransformfield instead ofGetComponent<RectTransform>()for performance
Common Pitfalls
ExecuteAlways runs in edit mode All Unity lifecycle methods (Awake, OnEnable, Update, etc.) run outside play mode. If your subclass performs game logic in these methods, guard them with if (Application.isPlaying) to avoid unintended side effects during editing.
RectTransform lazy initialization The rectTransform field is lazily initialized via GetComponent<RectTransform>() in the RectSize getter. If you access rectTransform directly before RectSize is called, it may be null. Either access RectSize first or initialize rectTransform in your Awake() or OnEnable().
Examples
Basic UI Element
See Also
ParagonBehaviour — parent class
IParagonBehaviour — interface this class satisfies
Objects Overview — system overview
Last updated