8ydilnik

Drive/ loadLine

Sep 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Drive : MonoBehaviour
  6. {
  7.  
  8.     public GameObject ControllerButton;
  9.     public GameObject OpenTheDoorAndTurnLight;
  10.     public GameObject DriveButton;
  11.  
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.         DriveButton.SetActive(false);
  16.         ControllerButton.SetActive(false);
  17.     }
  18.  
  19.     // Update is called once per frame
  20.     void Update()
  21.     {
  22.        
  23.     }
  24.  
  25.     public void StartDrive()
  26.     {
  27.         ControllerButton.SetActive(true);
  28.         OpenTheDoorAndTurnLight.SetActive(false);
  29.         DriveButton.SetActive(false);
  30.     }
  31. }
  32.  
  33. ////
  34.  
  35. using System.Collections;
  36. using System.Collections.Generic;
  37. using UnityEngine;
  38. using UnityEngine.UI;
  39. using UnityEngine.SceneManagement;
  40.  
  41. public class AssyncLoad : MonoBehaviour
  42. {
  43.     public int scene;
  44.     public GameObject button;
  45.     public GameObject sliderObj;
  46.     public Slider slider;
  47.     //start Coroutine
  48.     public void load()
  49.     {
  50.         StartCoroutine(loadscene());
  51.  
  52.     }
  53.     //signature to event
  54.     public void Start()
  55.     {
  56.         iventsistem.instance.time += load;
  57.        
  58.     }
  59.     //routin
  60.     IEnumerator loadscene()
  61.     {
  62.         button.SetActive(false);
  63.         sliderObj.SetActive(true);
  64.  
  65.         AsyncOperation operation = SceneManager.LoadSceneAsync(scene);
  66.         //while done
  67.         while (!operation.isDone)
  68.         {
  69.             float progress = Mathf.Clamp01(operation.progress / .9f);
  70.             slider.value = progress;
  71.             yield return null;
  72.  
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment