Skip to content

Commit fcb6b96

Browse files
committed
Check that file exists before parsing.
1 parent a28afb9 commit fcb6b96

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Scripts/env.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,19 @@ public static Dictionary<string, string> ParseEnvironmentFile()
6666
{
6767

6868
#if UNITY_EDITOR
69-
return ParseEnvironmentFile(File.ReadAllText(editorFilePath, Encoding.UTF8));
69+
if (File.Exists(editorFilePath))
70+
{
71+
return ParseEnvironmentFile(File.ReadAllText(editorFilePath, Encoding.UTF8));
72+
}
7073
#else
71-
return ParseEnvironmentFile(((TextAsset)Resources.Load(filename)).text);
74+
var contents = Resources.Load<TextAsset>(filename);
75+
76+
if (contents)
77+
{
78+
return ParseEnvironmentFile(contents.text);
79+
}
7280
#endif
81+
return new Dictionary<string, string>();
7382

7483
}
7584

0 commit comments

Comments
 (0)