skip to Main Content

Scripting Support (C#)

Call “TransitionAnimator.Start( .. parameters ..)” to run a transition.

TransitionPlus.TransitionAnimator.Start(
TransitionType.Fade, // transition type
duration: 2f, // transition duration in seconds
… (additional options are available)
);

Note: “TransitionPlus” above is the namespace. Check the script included in the On Demand demo scene forexamples.The full definition of the Start method with all optional parameters is below. Each parameter correspondsto the options displayed in the Transitions Plus inspector. Note that some parameters are used by onlycertain effects:

public static TransitionAnimator Start(
TransitionType type,
float duration = 2f,
Color color = default,
Gradient gradient = null,
Texture2D texture = null,
Vector2
center = default,
bool aspectRatio = false,
float rotation = 0,
float rotationMultiplier = 0,
float toonDotIntensity = 0,
int toonGradientIntensity = 1,
float noiseIntensity = 0.5f,
Texture2D noiseTex = null,
Vector2 noiseScale
= default,
bool invert = false,
bool autoDestroy = true,
float vignetteIntensity = 0.5f,
float contrast = 1f,
int splits = 5,
int centersCount = 8,
int seed = 0,
int cellsDivisions = 64,
float spread = 16f,
float destroyDelay = 1,
string sceneN
ameToLoad = null,
LoadSceneMode sceneLoadMode = LoadSceneMode.Single,
AudioClip sound = null,
bool fadeToCamera = false,
Camera mainCamera = null,
Camera secondCamera = null,
bool switchActiveCamera = true)

To load a new scene when transition ends use:

TransitionPlus.
TransitionAnimator.Start(
TransitionType.Fade, // transition type
duration: 2f,
// transition duration in seconds
sceneNameToLoad: “sceneName”
);

To transition from one camera to another:

TransitionPlus.TransitionAnimator.Start(
TransitionType.Fade, // transition type
duration: 2f, // transition duration in seconds
fadeToCamera: true,
mainCamera: xxx // the starting camera>,
secondCamera: xxx // the final camera
);

The Start method returns the reference to the transition component, which you can use to furthercustomize the transition before it actually starts:

TransitionAnimator animator = TransitionPlus.TransitionAnimator.Start(...);
animator.colorMode = ColorMode.Texture;
animator...
You can use the OnTransitionEnd event to get a callback when transition ends:
TransitionAnimator animator = TransitionAnimator.Start(TransitionType.Fade, duration: 2f);
animator.onTransitionEnd += myCallb
ack;
...
void myCallback() {
Debug.Log("end of transition");

Additionally add other events to happen, like in the following example:

using UnityEngine;
using TransitionsPlus;

public class TriggerController : MonoBehaviour
{
    // This function is called when an object enters the trigger collider
    private void OnTriggerEnter(Collider other)
    {
        TransitionAnimator.Start(TransitionType.Wipe, rotation: 90, contrast: 500f), noiseIntensity: 0.5f;
    }
}

Other useful methods:

  • SetProfile (profile): assigns a transition profile at runtime.
  • SetProgress(float t): manually sets the progress of transition (0-1).
  • Play(): Start transition when Auto Play is disabled.

Code Controlled Transition Demo Scene

Back To Top