Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.83 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. //About mini intro scene
  4. public class Load_Scene : MonoBehaviour {
  5.  
  6.     private string next_scene="Main_Scene";
  7.     private GameObject logo;
  8.     private GameObject logo_;
  9.     private GameObject Intro;
  10.     private float aux_var=0;
  11.     private bool sw1=false;
  12.     private bool sw2=false;
  13.     private bool sw3=false;
  14.     private Animator anim;
  15.     private bool intro_finished=false;
  16.     private bool one_clip=false;
  17.  
  18.     // Use this for initialization
  19.     void Start () {
  20.         setLayer();
  21.         logo = GameObject.Find("logo");
  22.         logo_ = GameObject.Find("logo_");
  23.         Intro = GameObject.Find("Intro");
  24.         Invoke ("fade_out_Logo",1);
  25.     }
  26.  
  27.     void setLayer(){
  28.         if(LayerMask.NameToLayer("Default")!=-1){
  29.             this.gameObject.layer = LayerMask.NameToLayer("UI");
  30.         }else{
  31.             Debug.Log("No ''UI'' layer was found, please create it on Inspector");
  32.         }
  33.     }
  34.  
  35.     // Update is called once per frame
  36.     void Update () {
  37.         Color aux = logo_.GetComponent<SpriteRenderer>().material.color;
  38.         if((aux.a >=0)&&(sw1==true)){
  39.             aux.a = aux.a - 0.01f;
  40.             logo_.GetComponent<SpriteRenderer>().material.color = aux;
  41.             if(sw3==false){Invoke ("fade_in_Logo",3);}
  42.         }
  43.         if((aux.a <=1)&&(sw2==true)){
  44.             aux.a = aux.a + 0.01f;
  45.             logo_.GetComponent<SpriteRenderer>().material.color = aux;
  46.             sw3=true;
  47.             Invoke ("fade_out_Logo",3);
  48.         }
  49.         if(intro_finished==true){fade_out_Intro ();}
  50.     }
  51.  
  52.     void fade_out_Logo(){
  53.         if(sw3==true){
  54.             NextScene();
  55.             Destroy(logo);
  56.         }
  57.         sw1=true;
  58.         sw2=false;
  59.     }
  60.  
  61.     void fade_in_Logo(){
  62.         sw1=false;
  63.         sw2=true;
  64.     }
  65.  
  66.     void NextScene(){Application.LoadLevel("MainMenu");}
  67.  
  68.     void fade_out_Intro(){
  69.         Color auxi = Intro.GetComponent<SpriteRenderer>().material.color;
  70.         if((auxi.a >=0)){
  71.             auxi.a = auxi.a - 0.01f;
  72.             Intro.GetComponent<SpriteRenderer>().material.color = auxi;
  73.         }else{
  74.             NextScene ();
  75.         }
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement