Fade In Splash Screen

Membuat Splash Screen Pada Unity 3d

Buat GameObject -> CreateEmpty
Add Component -> Rendering ->GUITexture
Atur posisi :

Masukkan dua Buah gambar /image ke Asset : Import New Assets atau klik and drag aja.....
Lalu pada GUITextture arahkan ke gambar yang diinginkan sebagai background.

Buat Code sbb:

using UnityEngine;
using System.Collections;

public class SplashScreen : MonoBehaviour {
 Texture2D blackTexture;
 float fadeSpeed = 5.0f;
 float alpha = 1.0f;
 float DelayTime = 3;
 public string WhatScene;

 // Use this for initialization
  void Start () {
           alpha = 1.0f;
           blackTexture = new Texture2D(1,1);
           blackTexture.SetPixel(0,0,Color.black);
           blackTexture.Apply();
      }
  void LoadingScene () {
           Application.LoadLevel(WhatScene);      
      }
  // Update is called once per frame
  void Update () {    }
  void OnGUI(){
           if (alpha > -1){
                 alpha -= fadeSpeed * Time.deltaTime / 10;
                 Color temp = GUI.color;
                 temp.a = alpha;
                 GUI.color = temp;
                 GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), blackTexture);
            } else {
                 Invoke("LoadingScene",DelayTime);
            }
      }
 }

++++++++++++++++++
Masukkan ke GameObject dan Tuliskan What Scene: SceneTujuan


Selamat mencoba.....
salam....
http://www.lp2maray.com















Fade In Splash Screen Fade In Splash Screen Reviewed by ADIARRAY on 18.44 Rating: 5

Tidak ada komentar:

Diberdayakan oleh Blogger.