In the project to use to load the scene when there is a gradual fade out of the effect, do a bit, to share with you
First, create two scenes of main and game scenes;
Next, create a FandeScene.cs script in the main scene, create a fade empty object, mount it, give a black picture, drag it into a preset, and drag it into the game scene.
using unityengine;using system.collections;public class fadescene : monobehaviour { public texture blacktexture; private float alpha = 1.0f; public float fadespeed = 0.2f; private int fadedir = -1; // Use this for initialization void Start () { } // update is called once per frame void Update () { } void ongui () { alpha += fadedir * fadespeed * time.deltatime; gui.color = new color (Gui.color .r ,gui.color .g ,gui.color .b,alpha); gui. drawtexture (new rect (0,0,screen .width ,screen .height), blackTexture); } public float beginfade (int direction) { fadeDir = direction; return 1 / fadespeed; } void onlevelwasloaded () { Debug.Log ("Scene loading is complete! "); beginfade ( -1); }}
Again, load the scene
CO preempted IEnumerator Fadeloadscene () {Float time = Gameobject.find ("Fade"). Getcomponent <FadeScene> (). Beginfade (1); Yield return new waitforseconds (time); Scenemanager.loadsceneasync ("Game"); }
If you run this way, the fade-in effect will appear.
This article is from the "Unity_3d Technology discussion" blog, please be sure to keep this source http://myselfdream.blog.51cto.com/9944020/1828525
Unity enables scene loading fade-in fade-out effect