コード例 #1
0
        private static void LoadSettings(VRPlatform platform)
        {
            if (_loadedSettings)
            {
                return;
            }

            // Get control and camera settings.
            _controlSettings = TBDataManager.DeserializeFromFile <TBControlSettings>(settingsFolder + controlSettingsFileName, TBDataManager.PathType.ResourcesFolder);
            if (!_controlSettings.supports3DOFControllers && !_controlSettings.supportsClickRemote && !_controlSettings.supportsGamepad && !_controlSettings.supportsHandControllers)
            {
                UnityEngine.Debug.LogWarning("No controller types are enabled in TBInput's settings!");
            }
            PrintControlSettings();
            _cameraSettings = TBDataManager.DeserializeFromFile <TBCameraSettings>(settingsFolder + cameraSettingsFilename, TBDataManager.PathType.ResourcesFolder);

            // Setup platform settings subclass.
            switch (platform)
            {
            case VRPlatform.OculusPC:
            case VRPlatform.OculusMobile:
                _settingsBase = TBCore.instance.gameObject.AddComponent <TBOculusSettings>();
                break;

                #if TB_HAS_UNITY_PS4
            case VRPlatform.PlayStationVR:
                _settingsBase = TBCore.instance.gameObject.AddComponent <TBSettingsPSVR>();
                break;
                #endif
            case VRPlatform.WindowsMR:
                _settingsBase = TBCore.instance.gameObject.AddComponent <TBWindowsMRSettings>();
                break;

            case VRPlatform.SteamVR:
                _settingsBase = TBCore.instance.gameObject.AddComponent <TBSteamVRSettings>();
                break;

            case VRPlatform.Daydream:
                _settingsBase = TBCore.instance.gameObject.AddComponent <TBGoogleSettings>();
                break;

            default:
                _settingsBase = TBCore.instance.gameObject.AddComponent <TBSettingsBase>();
                break;
            }
            _settingsBase.Initialize();

            // Apply quality settings overrides if needed.
            if (_settingsBase.GetDisplaySettings().qualitySettings.enableQualitySettingsOverride)
            {
                ApplyQualitySettingsOverrides(_settingsBase.GetDisplaySettings().qualitySettings);
            }

            // Set timestep.
            SetTimestep();

            _loadedSettings = true;
        }
コード例 #2
0
ファイル: TBInput.cs プロジェクト: tomires/jackout
        /// <summary>
        /// Loads a button set from JSON by its filename.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="buttons"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static List <ButtonDef <T> > LoadButtonDefs <T>(List <ButtonDef <T> > buttons, string fileName)
        {
            if (Application.isPlaying)
            {
                TBLogging.LogMessage("Loading button maps from " + TBSettings.settingsFolder + fileName + "...");
            }

            SerializedButtonDef[] serializedButtonDefs = TBDataManager.FromJsonWrapper <SerializedButtonDef>(TBDataManager.DeserializeFromFile <TBDataManager.Wrapper <TBInput.SerializedButtonDef> >(TBSettings.settingsFolder + fileName, TBDataManager.PathType.ResourcesFolder));

            if (serializedButtonDefs == null)
            {
                if (Application.isPlaying)
                {
                    TBLogging.LogWarning("Serialized button maps for " + fileName + " were invalid (empty file). Using defaults.");
                }
                return(buttons);
            }

            if (serializedButtonDefs.Length != buttons.Count)
            {
                TBLogging.LogError("Serialized button maps for " + fileName + " exist, but are invalid! (Input count mismatch). You need to clear the JSON file or manually fix it.");
            }

            for (int i = 0; i < buttons.Count; i++)
            {
                buttons[i].virtualButtons = serializedButtonDefs[i].virtualButtons;
            }

            if (Application.isPlaying)
            {
                TBLogging.LogMessage("Done! Found maps for " + buttons.Count + " buttons in " + TBSettings.settingsFolder + fileName + ".");
            }

            return(buttons);
        }