FadeableMono is an abstract MonoBehaviour base class for components that need fade in/out functionality. It provides lifecycle-based fade actions that can be configured in the Inspector.

It lives in the com.cupkekgames.fadeables package (namespace CupkekGames.Fadeables), one of Luna's bundled foundation dependencies — so it's available in any Luna project without an extra install. For fading UI Toolkit elements specifically, Luna's own FadeUIElement is the right tool; FadeableMono targets GameObjects and world objects.

Features

  • Automatic initialization of the Fadeable system
  • Lifecycle action fields for declarative fade behavior
  • Inspector-configurable without writing code

FadeableAction Enum

The FadeableAction enum defines the possible actions that can be triggered during Unity lifecycle events:

ValueDescription
NoneNo action is performed
FadeInAnimates the element to its visible state
FadeOutAnimates the element to its hidden state
SetFadedInInstantly sets the element to visible (no animation)
SetFadedOutInstantly sets the element to hidden (no animation)

Lifecycle Action Fields

FadeableMono provides four configurable fields that determine what happens at each Unity lifecycle event:

FieldWhen Triggered
OnAwakeCalled during Awake()
OnEnableCalled during OnEnable()
OnDisableCalled during OnDisable()
OnDestroyCalled during OnDestroy()

Usage

Common Patterns

Start Hidden, Fade In On Enable

Perfect for UI panels that should appear with animation each time they're enabled:

csharp
// Inspector settings: // OnAwake: SetFadedOut // OnEnable: FadeIn

This configuration:

  1. Immediately hides the element when the component awakens
  2. Fades it in each time the GameObject becomes enabled

Fade Out On Disable

For elements that should animate out before being disabled:

csharp
// Inspector settings: // OnDisable: FadeOut

Note: The fade-out animation may not complete if the GameObject is disabled immediately. Consider using a coroutine or event-based approach for proper completion.

Accessing the Fadeable Instance

FadeableMono exposes its Fadeable instance publicly for additional control. Durations are public fields (_fadeInDuration / _fadeOutDuration), normally set in the Inspector:

csharp
public class MyFadeableComponent : FadeableMono { public void CustomFade() { // Access the Fadeable instance for manual control Fadeable._fadeInDuration = 0.5f; Fadeable.FadeIn(); } }

Built-in Implementations

The fadeables package ships three ready-to-use FadeableMono subclasses:

ClassDescriptionUsage
FadeableColorLerps between two Inspector colors (_colorStart_colorEnd) by the fade valueRead GetColor() (e.g. from an OnApply handler) and apply it to whatever you're tinting — it doesn't write to a Renderer itself
FadeablePositionOffsets the Transform from its start position by _offset × fade valueSet _offset in the Inspector — slide-in/slide-out applies automatically as the fade runs
FadeableScaleScales the Transform's initial localScale by the fade valueGrow/shrink applies automatically; tick _ignoreY to keep the Y axis at 1 (flatten-style hide)

See also

  • Fadeables package — package page: namespace, asmdefs, repository
  • FadeUIElement — Luna's fade driver for UI Toolkit elements (what UIViewComponent uses for view fades)
  • UIViewComponent — view-level Show/Hide built on the same fade concepts

Settings

Theme

Light

Contrast

Material

Dark

Dim

Material Dark

System

Sidebar(Light & Contrast only)

Light
Dark

Font Family

DM Sans

Wix

Inclusive Sans

AR One Sans

Direction

LTR
RTL