Skip to content

Commit 173424b

Browse files
added ability to get the Mixed Reality Toolkit's folder directory path
1 parent 4c5615b commit 173424b

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

Assets/MixedRealityToolkit/_Core/Utilities/Editor/Setup/EnforceEditorSettings.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ public class EnforceEditorSettings
1818

1919
private static BuildTargetGroup currentBuildTargetGroup = BuildTargetGroup.Unknown;
2020

21+
private static string mixedRealityToolkit_RelativeFolderPath = string.Empty;
22+
23+
public static string MixedRealityToolkit_RelativeFolderPath
24+
{
25+
get
26+
{
27+
if (string.IsNullOrWhiteSpace(mixedRealityToolkit_RelativeFolderPath))
28+
{
29+
if (!FindDirectory(Application.dataPath, "MixedRealityToolkit", out mixedRealityToolkit_RelativeFolderPath))
30+
{
31+
Debug.LogError("Unable to find the Mixed Reality Toolkit's directory!");
32+
}
33+
}
34+
35+
return mixedRealityToolkit_RelativeFolderPath;
36+
}
37+
}
38+
2139
static EnforceEditorSettings()
2240
{
2341
SetIconTheme();
@@ -148,9 +166,38 @@ private static bool IsNewSession()
148166
return false;
149167
}
150168

169+
private static bool FindDirectory(string directoryPathToSearch, string directoryName, out string path)
170+
{
171+
path = string.Empty;
172+
173+
var directories = Directory.GetDirectories(directoryPathToSearch);
174+
175+
for (int i = 0; i < directories.Length; i++)
176+
{
177+
if (directories[i].Contains(directoryName))
178+
{
179+
path = directories[i];
180+
return true;
181+
}
182+
183+
if (FindDirectory(directories[i], directoryName, out path))
184+
{
185+
return true;
186+
}
187+
}
188+
189+
return false;
190+
}
191+
151192
private static void SetIconTheme()
152193
{
153-
var icons = Directory.GetFiles($"{Application.dataPath}/MixedRealityToolkit/_Core/Resources/Icons");
194+
if (string.IsNullOrEmpty(MixedRealityToolkit_RelativeFolderPath))
195+
{
196+
Debug.LogError("Unable to find the Mixed Reality Toolkit's directory!");
197+
return;
198+
}
199+
200+
var icons = Directory.GetFiles($"{MixedRealityToolkit_RelativeFolderPath}/_Core/Resources/Icons");
154201
var icon = new Texture2D(2, 2);
155202

156203
for (int i = 0; i < icons.Length; i++)

0 commit comments

Comments
 (0)