MacOS attempted fix with file:// prefix

This commit is contained in:
Daniel Lovell
2024-09-25 18:35:00 -07:00
parent a829a05264
commit c0b95b2fa7
2 changed files with 21 additions and 3 deletions

View File

@@ -3,8 +3,17 @@ using UnityEngine;
using Newtonsoft.Json;
public static class ConfigLoader {
private static string NormalizePath(string path) {
if (Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.LinuxPlayer) {
if (!path.StartsWith("file://")) {
return "file://" + path;
}
}
return path;
}
public static SimulationConfig LoadSimulationConfig(string configFileName) {
string configFilePath = Path.Combine(Application.streamingAssetsPath, "Configs", configFileName);
string configFilePath = NormalizePath(Path.Combine(Application.streamingAssetsPath, "Configs", configFileName));
if (File.Exists(configFilePath)) {
string json = File.ReadAllText(configFilePath);
SimulationConfig config = JsonConvert.DeserializeObject<SimulationConfig>(json, new JsonSerializerSettings {
@@ -18,7 +27,7 @@ public static class ConfigLoader {
}
public static StaticConfig LoadStaticConfig(string configFileName) {
string configFilePath = Path.Combine(Application.streamingAssetsPath, "Configs/Models", configFileName);
string configFilePath = NormalizePath(Path.Combine(Application.streamingAssetsPath, "Configs/Models", configFileName));
if (File.Exists(configFilePath)) {
string json = File.ReadAllText(configFilePath);
StaticConfig config = JsonConvert.DeserializeObject<StaticConfig>(json, new JsonSerializerSettings {
@@ -31,6 +40,7 @@ public static class ConfigLoader {
}
}
public static void PrintSimulationConfig(SimulationConfig config)
{
if (config == null)