using Crosstales.Radio.Demo.Util; using Crosstales.Radio.Util; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; namespace Crosstales.Radio.Demo { [HelpURLAttribute("https://www.crosstales.com/media/data/assets/radio/api/class_crosstales_1_1_radio_1_1_demo_1_1_g_u_i_main.html")] public class GUIMain : MonoBehaviour { [Header("Settings")] [Tooltip("'RadioPlayer' from the scene (optional).")] public RadioPlayer Player; [Tooltip("'RadioManager' from the scene (optional).")] public RadioManager Manager; [Tooltip("'Orbit'-object from the scene (optional).")] public Orbit Orbit; [Header("UI Objects")] public GameObject RadioPanel; public Text Name; public Text Version; public Text Scene; public GameObject InternetNotAvailable; public GameObject AudioPanel; public GameObject FilterPanel; public GameObject SpectrumPanel; public GameObject Spectrum; public GameObject Visuals; public Toggle FullscreenToogle; public Text DownloadSize; public Text ElapsedTotalTime; [Header("Scene-Link")] public int IndexPreviousScene; public int IndexNextScene; private float delayCount = 1f; public void Start() { if (FullscreenToogle != null && !Screen.fullScreen) { FullscreenToogle.isOn = false; } if (Name != null) { Name.text = "Radio PRO"; } if (Version != null) { Version.text = "2.9.2"; } if (DownloadSize != null) { DownloadSize.text = Helper.FormatBytesToHRF(Context.TotalDataSize); } if (ElapsedTotalTime != null) { ElapsedTotalTime.text = Helper.FormatSecondsToHourMinSec(Context.TotalPlayTime); } if (Scene != null) { Scene.text = SceneManager.GetActiveScene().name; } } public void Update() { delayCount += Time.deltaTime; if (delayCount > 1f) { delayCount = 0f; if (DownloadSize != null) { DownloadSize.text = Helper.FormatBytesToHRF(Context.TotalDataSize); } if (ElapsedTotalTime != null) { ElapsedTotalTime.text = Helper.FormatSecondsToHourMinSec(Context.TotalPlayTime); } } if (InternetNotAvailable != null) { InternetNotAvailable.SetActive(!Helper.isInternetAvailable); } } public void AudioPanelEnabled(bool val) { if (AudioPanel != null) { AudioPanel.SetActive(val); } } public void FilterPanelEnabled(bool val) { if (FilterPanel != null) { FilterPanel.SetActive(val); } } public void RadioPanelEnabled(bool val) { if (RadioPanel != null) { RadioPanel.SetActive(val); } } public void SpectrumEnabled(bool val) { if (SpectrumPanel != null) { SpectrumPanel.SetActive(val); } if (Spectrum != null) { Spectrum.SetActive(val); } } public void VisualsEnabled(bool val) { if (Visuals != null) { Visuals.SetActive(val); } } public void OrbitEnabled(bool val) { if (Orbit != null) { Orbit.enabled = val; } } public void FullscreenEnabled(bool val) { Screen.fullScreen = val; } public void OpenAssetURL() { Application.OpenURL("https://www.assetstore.unity3d.com/#!/list/42213-crosstales?aid=1011lNGT&pubref=Radio PRO"); } public void OpenCTURL() { Application.OpenURL("https://www.crosstales.com"); } public void Open1FM() { Application.OpenURL("http://www.1.fm/"); } public void PreviousScene() { if (Manager != null) { Manager.StopAll(); } if (Player != null) { Player.Stop(); } Invoke("previousScene", 0.4f); } public void NextScene() { if (Manager != null) { Manager.StopAll(); } if (Player != null) { Player.Stop(); } Invoke("nextScene", 0.4f); } public void Quit() { if (!Application.isEditor) { Application.Quit(); } } private void previousScene() { SceneManager.LoadScene(IndexPreviousScene); } private void nextScene() { SceneManager.LoadScene(IndexNextScene); } } }