The FadeUIElement class manages the fading in and out of a VisualElement.
Info: When fading a UIView, always use the public Fade variable provided by the UIView to ensure UI Actions work correctly. Typically, you should use this Fade rather than creating a custom instance.
Only create a custom Fade instance if you need to fade a VisualElement independently of UIView.
public FadeUIElement(
MonoBehaviour coroutineRunner,
VisualElement visualElement,
EasingMode easingMode = EasingMode.EaseOutCirc,
bool debug = false)| Name | Type | Description |
|---|---|---|
| coroutineRunner | MonoBehaviour | MonoBehaviour that handles running coroutines. |
| visualElement | VisualElement | The VisualElement to be faded. |
| easingMode | EasingMode | Defines the easing effect applied during fade transitions. |
| debug | bool | Logs fade transitions. |
| Property | Type | Description |
|---|---|---|
| IsFadingIn | bool | Returns true if a fade-in transition is currently active. |
| IsFadingOut | bool | Returns true if a fade-out transition is currently active. |
| IsFading | bool | Returns true if any fade transition is currently active (either in or out). |
// Check if element is currently animating
if (myFade.IsFading)
{
Debug.Log("Fade in progress, please wait...");
return;
}
// Check specific direction
if (myFade.IsFadingIn)
{
// Currently fading in
}
else if (myFade.IsFadingOut)
{
// Currently fading out
}| Event | Description |
|---|---|
| OnFadeInStart | Fired when a fade-in transition begins. |
| OnFadeIn | Fired when a fade-in transition completes. |
| OnFadeOutStart | Fired when a fade-out transition begins. |
| OnFadeOut | Fired when a fade-out transition completes. |
// Subscribe to fade events
myFade.OnFadeInStart += () => Debug.Log("Starting fade in");
myFade.OnFadeIn += () => Debug.Log("Fade in complete");
myFade.OnFadeOutStart += () => Debug.Log("Starting fade out");
myFade.OnFadeOut += () => Debug.Log("Fade out complete");Fades the element to full opacity.
public void FadeIn()Fades the element to zero opacity.
public void FadeOut()Sets the duration of fade transitions in seconds.
public void SetDuration(float seconds)Returns the predefined duration of fade transitions. Note that it does not reflect the current active transition duration.
public float GetDuration()Sets the easing function for fade transitions.
public void SetEasing(EasingMode easingMode)Sets a delay before the fade transition begins.
public void SetFadeInDelay(float seconds)
public void SetFadeOutDelay(float seconds)Stops the current fade transition immediately.
public void Stop()// Create a fade controller for a panel
var fadeController = new FadeUIElement(this, myPanel);
fadeController.SetDuration(0.3f);
fadeController.SetEasing(EasingMode.EaseOutBack);
// Add delay before fade out
fadeController.SetFadeOutDelay(0.5f);
// Subscribe to completion
fadeController.OnFadeOut += () =>
{
Debug.Log("Panel hidden");
};
// Trigger fade out
fadeController.FadeOut();Settings
Theme
Light
Contrast
Material
Dark
Dim
Material Dark
System
Sidebar(Light & Contrast only)
Font Family
DM Sans
Wix
Inclusive Sans
AR One Sans
Direction