private void Awake() { instance = this; string deviceName = UnityEngine.XR.XRSettings.loadedDeviceName; Debug.Log(deviceName); switch (deviceName) { case ("Oculus"): currentPlatformID = PlatformID.Oculus; break; case ("OpenVR"): currentPlatformID = PlatformID.SteamVR; break; default: currentPlatformID = PlatformID.None; break; } // set up our platform properly. // find our platform info PlatformReferences platformData = perPlatformData.First(item => item.ID == Platform); InitPlatform(platformData); }
private void Awake() { instance = this; // set up our platform properly. // find our platform info PlatformReferences platformData = perPlatformData.First(item => item.ID == Platform); InitPlatform(platformData); }
void InitPlatform(PlatformReferences platformData) { // disable behaviours if (platformData.BehavioursToDisable != null) { foreach (Behaviour behaviour in platformData.BehavioursToDisable) { behaviour.enabled = false; } } // disable game objects if (platformData.ObjectsToDisable != null) { foreach (GameObject objectToDisable in platformData.ObjectsToDisable) { objectToDisable.SetActive(false); } } // enable behaviours if (platformData.BehavioursToEnable != null) { foreach (Behaviour behaviour in platformData.BehavioursToEnable) { behaviour.enabled = true; } } // enable game objects (this order was chosen because behaviours to enable might be // on disabled game objects, and making sure they're available at Awake() is a good idea) if (platformData.ObjectsToEnable != null) { foreach (GameObject objectToEnable in platformData.ObjectsToEnable) { objectToEnable.SetActive(true); } } currentPlatformReferences = platformData; }