Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3. using System.Collections;
  4. using ProgressBar;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class PromptWindow : MonoBehaviour
  8. {
  9.  
  10. public ProgressRadialBehaviour bar;
  11. public GameObject ProgressHolder;
  12.  
  13. public AsyncOperation _async;
  14.  
  15. public static PromptWindow Instance;
  16.  
  17.  
  18. void Start()
  19. {
  20. Instance = this;
  21. }
  22.  
  23. public void OnYesClicked()
  24. {
  25. ProgressHolder.SetActive(true);
  26. if(!SaveController.Instance.data.isAccelerator)
  27. TractorController.Instance.SendDowngradeBT();
  28. TractorController.Instance.TryToConnectBt = false;
  29. if (!SaveController.Instance.data.isAccelerator)
  30. {
  31. #if UNITY_STANDALONE
  32. WinBluetoothController.Instance.RequestDisconnect();
  33. #endif
  34. TractorController.Instance.UnpairBt();
  35. }
  36. StartCoroutine(ShowProgressBar());
  37. }
  38.  
  39. private IEnumerator ShowProgressBar()
  40. {
  41. Instance = this;
  42. yield return new WaitForSeconds(0.1f);
  43. _async = SceneManager.LoadSceneAsync("Menu");
  44. _async.allowSceneActivation = false;
  45. SaveController.Instance.SaveData();
  46. while (_async.progress < 0.85f)
  47. {
  48. yield return new WaitForEndOfFrame();
  49. }
  50. TractorController.Instance.GetScreenshot();
  51. _async.allowSceneActivation = true;
  52. yield return null;
  53.  
  54. }
  55.  
  56. void Update()
  57. {
  58. if (_async != null)
  59. {
  60. bar.Value = _async.progress * 100;
  61. }
  62.  
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement