• Stars
    star
    300
  • Rank 138,870 (Top 3 %)
  • Language
    C#
  • Created about 10 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Modular, extensible transitions in scene and between scenes

TransitionKit

Modular, extensible transitions in-scene and between scenes. TransitionKit aims to make transitions easy. The main gist of how it works is that when invoked it snaps a screenshot and sticks it on a quad (by default but you can override this behavior). This means that you can reuse any of your full screen image effects with TransitionKit since it works in fundamentally the exact same way.

Side notes: if you make any neat transitions feel free to send over a pull request so we can build up a nice library of useful transitions! If the shaders used in your transitions (or the included transitions) are not used anywhere else you have to tell Unity to still included them in the build. You can do this by opening Edit -> Project Settings -> Graphics and stick the shaders in the "Always Included Shaders": Graphics Settings

In-Scene Transitions

Various situations require that you obscure what is happening such as when a player dies in a platformer and you want to reposition back to a spawn point or level start. With TransitionKit, you can just start a transition which will obscure the screen then make any scene/camera modifications that you need to so that when the transition completes everything will be ready for the player to see.

Between Scene Transitions

Switching scenes with Unity in a classy-looking fashion can be tricky. TransitionKit aims to simplify the process. All of the built in transitions allow you to specify an optional new scene to load and they will wait for it to load before the screen is unobscured.

Show Me Some Code!

This is an example of doing a scene-to-scene transition using the included FadeTransition. The FadeTransition will fade to the specified Color and then fade out to the newly loaded scene. If you wanted to do this transition in-scene, you would just omit setting the nextScene field.

var fader = new FadeTransition()
{
	nextScene = 3,
	fadeToColor = Color.white
};
TransitionKit.instance.transitionWithDelegate( fader );

The PixelatorTransition is a bit different than the others. Rather than pixelate both out and then in it will pixelate out the current scene and then uses an animation to wipe/zoom the old scene out of the way. The reason it does this is because pixelating the new scene back in would result in a jarring change between the first and second scenes. It provides a bit of variety as well and shows how you can do animations on the quad displaying the screenshot.

var pixelater = new PixelateTransition()
{
	nextScene = 2,
	finalScaleEffect = PixelateTransition.PixelateFinalScaleEffect.ToPoint,
	duration = 1.0f
};
TransitionKit.instance.transitionWithDelegate( pixelater );

Custom Transitions

TransitionKit comes with a few transitions to get you started. The demo scene shows how to make a transition with an inspector for those that prefer going that route (it uses the standard Unity whirl image effect so you can also see how to convert your image effects to TransitionKit). There are also transitions that don't subclass MonoBehaviour as well. The basic idea is that you just implement TransitionKitDelegate interface and implement a few methods. Your TransitionKitDelegate class has a couple optional features:

  • you can provide a custom Shader by returning it via the shaderForTransition method (the Unlit/Texture shader will be used if you return null)
  • you can provide a custom Mesh by returning it via the meshForDisplay method (a quad will be used if you return null)
  • you can provide a custom Texture by returning it via the textureForDisplay method (a screenshot will be used if you return null)

TransitionKit will call your TransitionKitDelegate's onScreenObscured method as a coroutine and that is where you can setup your transition animations. When dealing with scene-to-scene transitions, you will not want to unobscure the screen until the new scene is loaded. To deal with that situation, the TransitionKit class has a waitForLevelToLoad method that you can yield on and it will return when the level is loaded.

Events

TransitionKit provides two events as well: onScreenObscured and onTransitionComplete. I'm pretty sure you can figure out when they are fired but if you can't just load up the demo scene and watch the logs.

License

Some of the transition shaders were adapted from GLSL-Transition.

Attribution-NonCommercial-ShareAlike 3.0 Unported with simple explanation with the attribution clause waived. You are free to use StateKit in any and all games that you make. You cannot sell StateKit directly or as part of a larger game asset.

More Repositories

1

Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
C#
1,799
star
2

CharacterController2D

C#
1,032
star
3

TouchKit

Gestures and input handling made sane for Unity
C#
896
star
4

GoKit

Lightweight tween library for Unity
C#
583
star
5

RecyclerKit

Object pool manager for Unity
C#
363
star
6

SpriteLightKit

Blended lighting system for Unity that works with standard Sprites
C#
227
star
7

StateKit

Dead simple, lightweight "states as objects" system
C#
220
star
8

ZestKit

Tween library for Unity. The best of GoKit and GoKitLite combined in an easy to use API
C#
156
star
9

Nez-Samples

Samples and demos of various Nez features
C#
148
star
10

zig-ecs

Zig
144
star
11

P31UnityAddOns

Mostly defunct. Features were added and components broken out in the *Kit repositories.
C#
142
star
12

zig-upaya

Zig-based framework for creating game tools and helper apps
Zig
124
star
13

MessageKit

Decoupled message sending system meant as a replacement for SendMessage and its variants.
C#
122
star
14

zig-gamekit

Companion repo for zig-renderkit for making 2D games
Zig
103
star
15

CameraKit2D

Framework for creating 2D camera systems
C#
95
star
16

zig-renderkit

Zig
54
star
17

zig-flecs

C
51
star
18

GoKitLite

A super duper lightweight tweening library for Unity
C#
51
star
19

SoundKit

C#
45
star
20

Unity-Ripgrep-Search-Tool

C#
42
star
21

P31TaskManager

General purpose task manager that provides a lot more control and power than a standard coroutine
C#
35
star
22

via

V 2D game library
V
29
star
23

UnityCgShaderTutorials

Source code for the Unity Cg Shaders tutorial series on YouTube: http://www.youtube.com/playlist?list=PLb8LPjN5zpx1tauZfNE1cMIIPy15UlJNZ
C#
27
star
24

V-C-Wrapper-Generator

Helper for generating Odin and V wrapper code from C source
C#
19
star
25

Simple-ECS-Sharp

C#
18
star
26

ecs-lua

A simple, hybrid ECS
Lua
17
star
27

zig-miniaudio

Zig
17
star
28

SpriteKit

DEFUNCT: Unity now has 2D tools built in. This is now not maintained.
C#
15
star
29

PaletteKit

Helpful editor classes for importing and displaying color palettes
JavaScript
12
star
30

LearningUnits

C#
10
star
31

Odin-Sublime-Text-Plugin

Python
9
star
32

ImGuiGL-Renderer

C#
9
star
33

zig-vulkan

C++
5
star
34

egui_curve_tool

Rust
4
star
35

zig-aya

Zig
4
star
36

App-Engine-Task-Manager

Python
3
star
37

Odin-Libs

C
3
star
38

v-temp-modules

V
3
star
39

zig-fmod

Zig
2
star
40

Hugo-Helper

macOS app for managing a Hugo website
C#
2
star
41

prime31.github.io

HTML
2
star
42

fips-flecs

fipsified version of the Flecs ECS
CMake
1
star