- Build 7 update broke the controllers because I did not include the "android.hardware.vr.headtracking" uses-feature in the manifest. Because of this, the headset was incorrectly registered as an Oculus Go. Looks like they started to enforce this setting in the latest update. - Added support for adjusting the grid size in the settings panel.
83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using UnityEngine;
|
|
|
|
namespace QuestAppLauncher
|
|
{
|
|
/// <summary>
|
|
/// Root config object
|
|
/// </summary>
|
|
[Serializable]
|
|
public class Config
|
|
{
|
|
/// <summary>
|
|
/// Grid size
|
|
/// </summary>
|
|
[Serializable]
|
|
public class GridSize
|
|
{
|
|
public int rows = 3;
|
|
public int cols = 3;
|
|
}
|
|
|
|
public GridSize gridSize = new GridSize();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Class responsible for loading / saving config into a config.json file.
|
|
/// </summary>
|
|
public class ConfigPersistence
|
|
{
|
|
// File name of app name overrides
|
|
const string ConfigFileName = "config.json";
|
|
|
|
/// <summary>
|
|
/// Load config from file
|
|
/// </summary>
|
|
/// <param name="config">Config object that will be overwritten</param>
|
|
static public void LoadConfig(Config config)
|
|
{
|
|
var configFilePath = Path.Combine(UnityEngine.Application.persistentDataPath, ConfigFileName);
|
|
if (File.Exists(configFilePath))
|
|
{
|
|
Debug.Log("Found config file: " + configFilePath);
|
|
var jsonConfig = File.ReadAllText(configFilePath);
|
|
|
|
try
|
|
{
|
|
JsonUtility.FromJsonOverwrite(jsonConfig, config);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.Log(string.Format("Failed to read config: {0}", e.Message));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("Did not find config file: " + configFilePath);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Save config to a file
|
|
/// </summary>
|
|
/// <param name="config"></param>
|
|
static public void SaveConfig(Config config)
|
|
{
|
|
var configFilePath = Path.Combine(UnityEngine.Application.persistentDataPath, ConfigFileName);
|
|
Debug.Log("Saving config file: " + configFilePath);
|
|
|
|
try
|
|
{
|
|
File.WriteAllText(configFilePath, JsonUtility.ToJson(config, true));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.Log(string.Format("Failed to read config: {0}", e.Message));
|
|
}
|
|
|
|
}
|
|
}
|
|
} |