SlotRacerSplashScreen.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // --------------------------------------------------------------------------------------------------------------------
  2. // <copyright file="SlotRacerSpashScreen.cs" company="Exit Games GmbH">
  3. // Part of: Photon Unity Networking Demos
  4. // </copyright>
  5. // <summary>
  6. // Used in SlotRacer Demo
  7. // </summary>
  8. // <author>developer@exitgames.com</author>
  9. // --------------------------------------------------------------------------------------------------------------------
  10. using UnityEngine;
  11. using UnityEngine.UI;
  12. #if UNITY_EDITOR
  13. using UnityEditor;
  14. #endif
  15. namespace Photon.Pun.Demo.SlotRacer
  16. {
  17. /// <summary>
  18. /// Slot racer splash screen. Inform about the slotRacer demo and the Cockpit control setup
  19. /// Gets deleted as soon as the scene plays
  20. /// </summary>
  21. [ExecuteInEditMode]
  22. public class SlotRacerSplashScreen : MonoBehaviour
  23. {
  24. #pragma warning disable 0414
  25. private string PunCockpit_scene = "PunCockpit-Scene";
  26. #pragma warning restore 0414
  27. public Text WarningText;
  28. public GameObject SplashScreen;
  29. private void Start()
  30. {
  31. if (Application.isPlaying)
  32. {
  33. Destroy(this.SplashScreen);
  34. Destroy(this);
  35. }
  36. }
  37. public void Update()
  38. {
  39. #if UNITY_EDITOR
  40. if (!Application.isPlaying)
  41. {
  42. if (this.WarningText == null)
  43. {
  44. return;
  45. }
  46. bool _found = false;
  47. bool _enabled = false;
  48. foreach (EditorBuildSettingsScene _scene in EditorBuildSettings.scenes)
  49. {
  50. if (_scene.path.EndsWith(this.PunCockpit_scene + ".unity"))
  51. {
  52. _found = true;
  53. _enabled = _scene.enabled;
  54. break;
  55. }
  56. }
  57. if (_found && _enabled)
  58. {
  59. this.WarningText.text = string.Empty;
  60. return;
  61. }
  62. if (_found && !_enabled)
  63. {
  64. this.WarningText.text = "<Color=Green>INFORMATION:</Color>\nThis demo can run with the PunCockpit Scene." +
  65. "\nFor this, the Scene '" +
  66. this.PunCockpit_scene +
  67. "' needs to be enabled to the build settings." +
  68. "\nElse, you'll get only a minimal Menu to connect";
  69. return;
  70. }
  71. if (!_found)
  72. {
  73. this.WarningText.text = "<Color=Green>INFORMATION:</Color>\nThis demo can run with the PunCockpit Scene." +
  74. "\n For this, the Scene '" +
  75. this.PunCockpit_scene +
  76. "' needs to be added to the build settings." +
  77. "\nElse, you'll get only a minimal Menu to connect";
  78. }
  79. }
  80. #endif
  81. }
  82. }
  83. }