X Tutup

Scripting Support (C#)

advanced scripting

Transitions Plus · Scripting Support (C#)

Class: All members on this page belong to the TransitionAnimator component (namespace TransitionsPlus). Access via GetComponent<TransitionAnimator>().
Tip: Check the demo scene scripts included in the package for runtime usage examples.

Getting Started

Add using TransitionsPlus; at the top of your script. Transitions can be started with a single static call:

using TransitionsPlus;

// Quick start with a profile asset
TransitionAnimator.Start(myTransitionProfile);

// Quick start with inline parameters
TransitionAnimator.Start(TransitionType.Fade, duration: 2f, color: Color.black);

TransitionAnimator (Component)

Properties

float progress { get; set; }

Current animation progress from 0 (start) to 1 (end). Default: 0.

bool isPlaying { get; }

Whether the transition is currently animating (read-only).

TransitionProfile profile { get; set; }

The transition profile currently in use. Default: null.

bool showInEditMode

Show the transition canvas while not in Play Mode. Default: true.

bool autoPlay

Automatically start the transition when the GameObject activates. Default: true.

float playDelay

Delay in seconds before starting the transition. Default: 0.

bool useUnscaledTime

Use unscaled time so the transition is not affected by Time.timeScale. Default: false.

bool autoDestroy

Automatically remove the transition from the scene when finished. Default: false.

float destroyDelay

Delay in seconds before destroying the transition after it finishes. Default: 0.

bool destroyAllTransitions

When autoDestroy is enabled, destroy all transitions in the scene instead of just this one. Default: false.

RenderMode renderMode

Rendering mode: FullScreen, InsideUI (renders inside a RawImage), or VR. Default: RenderMode.FullScreen.

RawImage customScreen

Custom RawImage target when renderMode is set to InsideUI. Default: null.

int sortingOrder

Canvas sorting order, useful when launching several animations at the same time. Default: 100.

UnityEvent onTransitionEnd()

Event triggered when the transition animation ends.

bool loadSceneAtEnd

Load a scene when the transition finishes. Default: false.

string sceneNameToLoad

Name of the scene to load at transition end.

LoadSceneMode sceneLoadMode

Scene loading mode. Default: LoadSceneMode.Single.

bool fadeToCamera

Enable camera-to-camera fade transition. Default: false.

Camera mainCamera

Primary camera for the transition. Auto-resolved to Camera.main if not set.

Camera secondCamera

Secondary camera for camera-to-camera transitions. Default: null.

bool switchActiveCamera

Automatically toggle main/second camera active states during and after the transition. Default: true.

bool keepSecondCameraActive

Keep the second camera active while the transition is being performed. Default: false.

bool autoFollow

Make the animation center follow a target GameObject. Default: false.

Transform followTarget

Target transform to follow when autoFollow is enabled. Default: null.

Vector3 followPositionOffset

Offset added to the followed target position. Default: (0, 0, 0).

Methods

void Play()

Play the transition from the beginning.

void SetProgress(float t)

Manually set the animation progress (0 to 1).

t
Progress value from 0 (start) to 1 (end).
void SetProfile(TransitionProfile profile)

Change the transition profile at runtime.

void PlayAudio()

Play the sound effect assigned to the current profile.

void UpdateMaterialProperties()

Refresh all shader material properties. Called automatically but can be triggered manually after changing profile values.

Static Factory Methods

Both overloads return the TransitionAnimator instance, which you can use to set additional properties like useUnscaledTime that are not available as parameters.

static TransitionAnimator Start(TransitionProfile profile, ...)

Start a transition from a profile asset. All parameters are optional except profile.

profile
TransitionProfile - The profile asset to use (required).
autoDestroy
bool - Remove the transition when finished. Default: true.
destroyDelay
float - Seconds to wait before destroying. Default: 1.
sceneNameToLoad
string - Scene to load when transition ends. Default: null.
sceneLoadMode
LoadSceneMode - Default: Single.
fadeToCamera
bool - Enable camera-to-camera transition. Default: false.
mainCamera
Camera - Primary camera. Default: null (auto-resolved).
secondCamera
Camera - Secondary camera. Default: null.
switchActiveCamera
bool - Auto-toggle cameras. Default: true.
autoFollow
bool - Follow a target. Default: false.
followTarget
Transform - Target to follow. Default: null.
sortingOrder
int - Canvas sorting order. Default: unchanged.
playDelay
float - Delay before starting. Default: 0.
followPositionOffset
Vector3 - Follow offset. Default: (0,0,0).
renderMode
RenderMode - Default: FullScreen.
customScreen
RawImage - Target for InsideUI mode. Default: null.
static TransitionAnimator Start(TransitionType type, ...)

Start a transition with inline customization. Creates a temporary profile. All parameters are optional except type. Includes all parameters from the profile-based overload above, plus:

type
TransitionType - The transition effect (required).
duration
float - Duration in seconds. Default: 2.
color
Color - Solid color. Default: Color.black.
gradient
Gradient - Gradient (sets colorMode to Gradient). Default: null.
texture
Texture2D - Texture (sets colorMode to Texture). Default: null.
center
Vector2 - Animation center offset. Default: (0,0).
keepAspectRatio
bool - Prevent stretching. Default: false.
rotation
float - Rotation in degrees. Default: 0.
rotationMultiplier
float - Rotation speed. Default: 0.
toonDotIntensity
float - Default: 0.
toonGradientIntensity
int - Default: 1.
noiseIntensity
float - Default: 0.5.
noiseTex
Texture2D - Noise texture. Default: null (built-in).
noiseScale
Vector2 - Default: (1,1).
invert
bool - Invert direction. Default: false.
vignetteIntensity
float - Default: 0.5.
contrast
float - Default: 1.
splits
int - Default: 5.
centersCount
int - Default: 8.
seed
int - Default: 0.
cellsDivisions
int - Default: 64.
spread
float - Default: 16.
sound
AudioClip - Sound effect. Default: null.
timeMultiplier
float - Speed multiplier. Default: 1.
shapeTexture
Texture2D - SDF shape. Default: null (built-in).
pixelization
int - Default: 0 (disabled).
randomize
bool - Randomize seed. Default: false.
progressFrom
float - Progress value at which the visual transition begins. Default: 0.
progressTo
float - Progress value at which the visual transition completes. Default: 1.
Note: Properties like useUnscaledTime, destroyAllTransitions, and keepSecondCameraActive are not available as parameters in the static Start() methods. Set them on the returned instance:
var ta = TransitionAnimator.Start(TransitionType.Fade, duration: 0.5f);
ta.useUnscaledTime = true;

TransitionProfile (ScriptableObject)

A TransitionProfile is a ScriptableObject that holds all visual settings for a transition. Create one via Assets > Create > Transition Profile.

Properties

TransitionType type

The transition effect to use. Default: TransitionType.Fade.

bool invert

Invert the transition direction. Default: false.

float duration

Transition duration in seconds. Default: 2.

float timeMultiplier

Speed multiplier for the transition. Values greater than 1 speed up, less than 1 slow down. Default: 1.

float progressFrom

Raw progress value (0-1) at which the visual transition begins. Default: 0.

float progressTo

Raw progress value (0-1) at which the visual transition completes. Events and camera switches fire at this point. Default: 1.

ColorMode colorMode

Color source: SingleColor, Gradient, or Texture. Default: ColorMode.SingleColor.

Color color

Solid color used when colorMode is SingleColor. Default: Color.black.

Gradient gradient

Gradient used when colorMode is Gradient. Default: white-to-white.

GradientMode gradientMode

How the gradient is applied: Opacity, Time, SpatialRadial, SpatialHorizontal, or SpatialVertical. Default: GradientMode.Opacity.

Texture texture

Texture used when colorMode is Texture. Default: null.

Texture2D shapeTexture

SDF shape texture for the Shape transition type. Default: built-in star SDF.

float noiseIntensity

Noise effect intensity. Range: 0-1. Default: 0.5.

Texture2D noiseTexture

Noise texture. Default: built-in noise texture.

Vector2 noiseScale

Scale of the noise texture. Default: (1, 1).

float vignetteIntensity

Vignette effect intensity (Fade type only). Range: 0-1. Default: 1.

int toonGradientIntensity

Toon gradient banding intensity. Range: 1-256. Default: 64.

float toonDotIntensity

Toon dot pattern intensity. Range: 0-1. Default: 0.5.

float toonDotRadius

Radius of toon dots. Range: 0.01-0.8. Default: 0.333.

int toonDotCount

Number of toon dots. Min: 8. Default: 32.

float rotation

Rotation angle in degrees. Default: 0.

float rotationMultiplier

Rotation speed multiplier during animation. Default: 0.

float distortion

Edge distortion amount. Range: 0-5. Default: 0.

int splits

Number of splits for applicable transition types. Min: 1. Default: 2.

Vector2 center

Animation center offset. Clamped to (-1, -1) to (2, 2). Default: (0, 0).

bool keepAspectRatio

Compensate for screen width/height difference to prevent stretching. Default: false.

bool randomize

Randomize the seed on each play. Default: false.

int seed

Random seed for procedural effects. Min: 0. Default: 0.

int centersCount

Number of effect centers for Burn, BurnSquare, and Splash types. Range: 1-32. Default: 16.

int cellDivisions

Number of cell divisions for Mosaic, Dissolve, Tiles, and similar types. Min: 1. Default: 32.

float spread

Spread factor for Mosaic and Spiral types. Min: 1. Default: 64.

float contrast

Edge contrast. Min: 1. Default: 1.

int pixelization

Pixelization level. Range: 0-128. Default: 0 (disabled).

Texture2D splashTexture

Texture for the Splash transition type. Default: built-in splash texture.

AudioClip sound

Optional sound effect to play during the transition. Default: null.

float soundDelay

Delay in seconds before playing the sound. Min: 0. Default: 0.

TransitionType (Enum)

Available transition effects:

Fade, Mosaic, Dissolve, Tiles, Shape, Wipe, DoubleWipe, CrossWipe, CircularWipe, Burn, BurnSquare, Splash, SeaWaves, Screen, Smear, Slide, DoubleSlide, Cube, Melt, Circles, Spiral, Pixelate, TilesProgressive, Warp, Ripple

RenderMode (Enum)

FullScreen — Render over entire screen. InsideUI — Render inside a UI RawImage. VR — Optimized for VR cameras.

Code Examples

using TransitionsPlus;

// Fade to black, then load a new scene
TransitionAnimator.Start(
    TransitionType.Fade,
    duration: 1.5f,
    color: Color.black,
    sceneNameToLoad: "GameLevel2"
);

// Camera-to-camera transition with a dissolve effect
TransitionAnimator.Start(
    TransitionType.Dissolve,
    duration: 2f,
    fadeToCamera: true,
    mainCamera: cam1,
    secondCamera: cam2,
    switchActiveCamera: true
);

// Use a profile asset with auto-destroy
TransitionAnimator.Start(myProfile, autoDestroy: true, destroyDelay: 0.5f);

// Manual control of transition progress
TransitionAnimator ta = TransitionAnimator.Start(myProfile, autoDestroy: false);
ta.SetProgress(0.5f); // Set to halfway
Was this page helpful?
X Tutup