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.

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:

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

Built-in Implementations

Luna provides several ready-to-use FadeableMono implementations:

ClassDescription
FadeableColorFades a Renderer's color/alpha
FadeablePositionAnimates position between two points
FadeableScaleAnimates scale for grow/shrink effects

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