Часто возникает необходимость в сглаживании переходов между сценами. Незамысловатое, простое решение. Создаем плейник, скейлим его, выставляем ротейшен и позишет, чтобы он полностью перекрывал обзор камере, на него натягивает текстуру(белую/ черную/ другую).На плейник вешаем скрипт приведенный ниже. Сохраняем префаб.
using UnityEngine;
using System.Collections;
public class LevelChange : MonoBehaviour
{
enum TransitDirection { Up, Down }
TransitDirection transitDirection=TransitDirection.Up;
private float alpha = 0f;
private Color start_color;
private MeshFilter mf;
private Mesh mesh;
private Color[] colors;
public string LevelNumber;
public float DeltaAlpha = 0.0005f;
void Start()
{
DontDestroyOnLoad(transform);
mf = gameObject.GetComponent<MeshFilter>();
mesh = mf.mesh;
start_color = new Color(0f, 0f, 0f, alpha);
colors = new Color[mesh.vertexCount];
for (int i = 0; i < colors.Length; i++)
{
colors[i] = start_color;
}
mesh.colors = colors;
mf.mesh = mesh;
}
void Update()
{
if(transitDirection==TransitDirection.Down)
{
if (Application.isLoadingLevel) return;
}
for (int i = 0; i < colors.Length; i++)
{
if (transitDirection == TransitDirection.Up) alpha += DeltaAlpha;
else alpha -= DeltaAlpha;
colors[i] = start_color;
colors[i].a = alpha;
}
mesh.colors = colors;
mf.mesh = mesh;
if (transitDirection==TransitDirection.Up)
{
if (alpha >= 1)
{
Application.LoadLevel(LevelNumber);
transitDirection = TransitDirection.Down;
}
}
else if (alpha <= 0.0001f) Destroy(gameObject);
}
}
В событие, вызывающее переход между уровнями передаем инстанс нашего плейника и левел, который грузим.
transitPlane=(GameObject)Instantiale(TransitPlane);
transitPlane.GetComponent<LevelChange>().LevelNumber = "Scene2";