using System.Collections.Generic; using Crosstales.Radio.Util; using UnityEngine; namespace Crosstales.Radio.Demo.Util { [HelpURLAttribute("https://www.crosstales.com/media/data/assets/radio/api/class_crosstales_1_1_radio_1_1_demo_1_1_util_1_1_platform_controller.html")] public class PlatformController : MonoBehaviour { [Header("Configuration")] [Tooltip("Selected platforms for the controller.")] public List Platforms; [Tooltip("Enable or disable the 'Objects' for the selected 'Platforms' (default: true).")] public bool Active = true; [Tooltip("Selected objects for the controller.")] [Header("Objects")] public GameObject[] Objects; private Platform currentPlatform; public void Start() { if (Helper.isWindowsPlatform) { currentPlatform = Platform.Windows; } else if (Helper.isMacOSPlatform) { currentPlatform = Platform.OSX; } else if (Helper.isAndroidPlatform) { currentPlatform = Platform.Android; } else if (Helper.isIOSPlatform) { currentPlatform = Platform.IOS; } else if (Helper.isWSAPlatform) { currentPlatform = Platform.WSA; } else if (Helper.isWebPlatform) { currentPlatform = Platform.Web; } else { currentPlatform = Platform.Unsupported; } bool active = ((!Platforms.Contains(currentPlatform)) ? (!Active) : Active); GameObject[] objects = Objects; foreach (GameObject gameObject in objects) { if (gameObject != null) { gameObject.SetActive(active); } } } } }