public IEnumerator TestAdHocDirectory() { string adhocTesting = MixedRealityToolkitModuleType.AdhocTesting.ToString(); string adHocFolderPath = Path.Combine(UnityEngine.Application.dataPath, adhocTesting); string adHocFolderMetaPath = Path.Combine(UnityEngine.Application.dataPath, adhocTesting + ".meta"); string adHocSentinelFilePath = Path.Combine(adHocFolderPath, "MRTK." + adhocTesting + ".sentinel"); try { Directory.CreateDirectory(adHocFolderPath); using (var file = File.Create(adHocSentinelFilePath)) { yield return(RefreshFiles()); var moduleType = MixedRealityToolkitModuleType.AdhocTesting; var dirs = MixedRealityToolkitFiles.GetDirectories(moduleType); Assert.IsNotNull(dirs, $"Directory list was null for module type {moduleType.ToString()}"); Assert.IsNotEmpty(dirs, $"Directory list was empty for module type {moduleType.ToString()}"); } } finally { // Clean up Directory.Delete(adHocFolderPath, true); File.Delete(adHocFolderMetaPath); } }
public override void OnInspectorGUI() { var testGltfLoading = this.target as TestGltfLoading; base.OnInspectorGUI(); var path = $"{Application.streamingAssetsPath}{testGltfLoading.Uri}"; path = path.Replace("/", "\\"); bool needsCopy = !File.Exists(path) && Application.isEditor; if (needsCopy) { EditorGUILayout.HelpBox("glTF path was not discovered in the streaming assets folder. Please copy over files to test example scene", MessageType.Warning); } if (GUILayout.Button("Copy GLTF Directory to Streaming Assets")) { string modelPath = MixedRealityToolkitFiles.MapRelativeFolderPathToAbsolutePath(MixedRealityToolkitModuleType.Examples, "Demos\\Gltf\\Models"); DirectoryCopy(modelPath, $"{Application.streamingAssetsPath}\\GltfModels"); #if UNITY_EDITOR UnityEditor.AssetDatabase.Refresh(UnityEditor.ImportAssetOptions.ForceUpdate); #endif Debug.Log("Copied glTF model files to Streaming Assets folder"); } }
protected virtual void Awake() { string assetPath = "StandardAssets/Textures"; if (logoLightTheme == null) { logoLightTheme = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath($"{assetPath}/MRTK_Logo_Black.png"), typeof(Texture2D)); } if (logoDarkTheme == null) { logoDarkTheme = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath($"{assetPath}/MRTK_Logo_White.png"), typeof(Texture2D)); } if (helpIcon == null) { helpIcon = EditorGUIUtility.IconContent("_Help").image; } if (WarningIconContent == null) { WarningIconContent = new GUIContent(EditorGUIUtility.IconContent("console.warnicon").image, "This profile is part of the default set from the Mixed Reality Toolkit SDK. You can make a copy of this profile, and customize it if needed."); } }
/// <summary> /// Validates that MixedRealityToolkitFiles is able to reason over MRTK folders when placed in the root Asset directory. /// </summary> public void TestRootAssetFolderResolution() { string resolvedPath = MixedRealityToolkitFiles.MapRelativeFilePathToAbsolutePath("Inspectors/Data/EditorWindowOptions.json"); string expectedPath = Path.Combine(Application.dataPath, "MixedRealityToolkit/Inspectors/Data/EditorWindowOptions.json"); Assert.AreEqual(expectedPath, resolvedPath); }
public IEnumerator TestNoneDirectory() { yield return(RefreshFiles()); var dirs = MixedRealityToolkitFiles.GetDirectories(MixedRealityToolkitModuleType.None); Assert.IsNull(dirs, $"Directory list should be null for module type {MixedRealityToolkitModuleType.None.ToString()}"); }
public IEnumerator TestRootAssetFolderResolution() { yield return(RefreshFiles()); string resolvedPath = MixedRealityToolkitFiles.MapRelativeFilePathToAbsolutePath("Inspectors\\Data\\EditorWindowOptions.json"); Assert.IsNotNull(resolvedPath); }
public void TestInvalidPath(string path) { foreach (string basePath in basePaths) { string fullPath = Path.Combine(basePath, path); Assert.False(MixedRealityToolkitFiles.FindMatchingModule(fullPath, out MixedRealityToolkitModuleType module)); } }
public IEnumerator TestMapModulePath() { yield return(RefreshFiles()); foreach (var moduleType in GetTestModulesTypes()) { Assert.IsNotNull(MixedRealityToolkitFiles.MapModulePath(moduleType), $"Module Path was null for module type {moduleType.ToString()}"); } }
private static void LoadTexture(ref Texture2D tex, string filename) { const string assetPath = "StandardAssets/Textures"; if (tex == null) { tex = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath(Path.Combine(assetPath, filename)), typeof(Texture2D)); } }
public void TestValidPath(string path, MixedRealityToolkitModuleType expectedModule) { foreach (string basePath in basePaths) { string fullPath = Path.Combine(basePath, path); Assert.True(MixedRealityToolkitFiles.FindMatchingModule(fullPath, out MixedRealityToolkitModuleType module)); Assert.AreEqual(module, expectedModule); } }
public IEnumerator TestGetDirectories() { yield return(RefreshFiles()); foreach (var moduleType in GetTestModulesTypes()) { var dirs = MixedRealityToolkitFiles.GetDirectories(moduleType); Assert.IsNotNull(dirs, $"Directory list was null for module type {moduleType.ToString()}"); Assert.IsNotEmpty(dirs, $"Directory list was empty for module type {moduleType.ToString()}"); } }
private static IEnumerator RefreshFiles() { MixedRealityToolkitFiles.RefreshFolders(); var task = MixedRealityToolkitFiles.WaitForFolderRefresh(); while (!task.IsCompleted) { yield return(null); } Assert.IsTrue(MixedRealityToolkitFiles.AreFoldersAvailable); }
/// <summary> /// Load pose data from files. /// </summary> public static void LoadGesturePoses() { string[] gestureNames = Enum.GetNames(typeof(GestureId)); string basePath = Path.Combine("InputSimulation", "ArticulatedHandPoses"); for (int i = 0; i < gestureNames.Length; ++i) { string relPath = Path.Combine(basePath, String.Format("ArticulatedHandPose_{0}.json", gestureNames[i])); string absPath = MixedRealityToolkitFiles.MapRelativeFilePath(MixedRealityToolkitModuleType.Services, relPath); LoadGesturePose((GestureId)i, absPath); } }
protected virtual void Awake() { string assetPath = "StandardAssets/Textures"; if (logoLightTheme == null) { logoLightTheme = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath($"{assetPath}/MRTK_Logo_Black.png"), typeof(Texture2D)); } if (logoDarkTheme == null) { logoDarkTheme = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath($"{assetPath}/MRTK_Logo_White.png"), typeof(Texture2D)); } }
public void StartUp() { FindShaders(); string assetPath = "StandardAssets/Textures"; if (logoLightTheme == null) { logoLightTheme = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath($"{assetPath}/MRTK_Logo_Black.png"), typeof(Texture2D)); } if (logoDarkTheme == null) { logoDarkTheme = (Texture2D)AssetDatabase.LoadAssetAtPath(MixedRealityToolkitFiles.MapRelativeFilePath($"{assetPath}/MRTK_Logo_White.png"), typeof(Texture2D)); } }
private static void UpdateTestScriptIcons() { var testDirectories = MixedRealityToolkitFiles.GetDirectories(MixedRealityToolkitModuleType.Tests); var directories = MixedRealityToolkitFiles.GetDirectories(MixedRealityToolkitModuleType.Tests); Texture2D icon = null; foreach (string iconPath in MixedRealityToolkitFiles.GetFiles("StandardAssets/Icons")) { if (iconPath.EndsWith("test_icon.png")) { icon = AssetDatabase.LoadAssetAtPath <Texture2D>(iconPath); break; } } if (icon == null) { Debug.Log("Couldn't find test icon."); return; } foreach (string directory in testDirectories) { string[] scriptGuids = AssetDatabase.FindAssets("t:MonoScript", new string[] { MixedRealityToolkitFiles.GetAssetDatabasePath(directory) }); for (int i = 0; i < scriptGuids.Length; i++) { string scriptPath = AssetDatabase.GUIDToAssetPath(scriptGuids[i]); EditorUtility.DisplayProgressBar("Updating Icons...", $"{i} of {scriptGuids.Length} {scriptPath}", i / (float)scriptGuids.Length); MonoScript script = AssetDatabase.LoadAssetAtPath <MonoScript>(scriptPath); Texture2D currentIcon = getIconForObject?.Invoke(null, new object[] { script }) as Texture2D; if (currentIcon == null || !currentIcon.Equals(icon)) { setIconForObject?.Invoke(null, new object[] { script, icon }); copyMonoScriptIconToImporters?.Invoke(null, new object[] { script }); } } } EditorUtility.ClearProgressBar(); }
private static Texture2D GetControllerTextureInternal(string relativeTexturePath, Handedness handedness, string suffix) { string handednessSuffix = string.Empty; if (handedness == Handedness.Left) { handednessSuffix = "_left"; } else if (handedness == Handedness.Right) { handednessSuffix = "_right"; } string themeSuffix = EditorGUIUtility.isProSkin ? "_white" : "_black"; string fullTexturePath = MixedRealityToolkitFiles.MapRelativeFilePath(MixedRealityToolkitModuleType.StandardAssets, $"{relativeTexturePath}{handednessSuffix}{themeSuffix}{suffix}.png"); return((Texture2D)AssetDatabase.LoadAssetAtPath(fullTexturePath, typeof(Texture2D))); }
public void VerifyGetAssetDatabasePath() { // File in the Assets folder structure string inputPath = @"c:\projects\MyUnityProject\Assets\materials\test.mat"; string expectedPath = "Assets/materials/test.mat"; string actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); // File in the Packages folder structure inputPath = "d:/source/projects/Packages/CoolFeature/textures/background.png"; expectedPath = "Packages/CoolFeature/textures/background.png"; actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); // File in the Library/PackageCache folder structure inputPath = @"c:\development\projects\space\Library\PackageCache\[email protected]\scriptable.asset"; expectedPath = "Packages/com.contoso.custompackage/scriptable.asset"; actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); // Edge cases inputPath = @"c:\projects\AssetsViewer\Assets\materials\test.mat"; expectedPath = "Assets/materials/test.mat"; actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); inputPath = "d:/source/projects/Packages/CoolFeature/MyAssets/textures/background.png"; expectedPath = "Packages/CoolFeature/MyAssets/textures/background.png"; actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); inputPath = @"c:\development\projects\space\Library\PackageCache\[email protected]\Core\StandardAssets\Textures\MRTK_Logo_Black.png"; expectedPath = "Packages/com.microsoft.mixedreality.toolkit.foundation/Core/StandardAssets/Textures/MRTK_Logo_Black.png"; actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); inputPath = @"c:\projects\AssetsViewer\Assets\StandardAssets\materials\test.mat"; expectedPath = "Assets/StandardAssets/materials/test.mat"; actualPath = MixedRealityToolkitFiles.GetAssetDatabasePath(inputPath); Assert.AreEqual(expectedPath, actualPath); }
public void TestGetDirectories() { MixedRealityToolkitModuleType[] moduleTypes = new MixedRealityToolkitModuleType[] { MixedRealityToolkitModuleType.Core, MixedRealityToolkitModuleType.Providers, MixedRealityToolkitModuleType.Services, MixedRealityToolkitModuleType.SDK, MixedRealityToolkitModuleType.Examples, MixedRealityToolkitModuleType.Tests, MixedRealityToolkitModuleType.Extensions, MixedRealityToolkitModuleType.Tools, }; MixedRealityToolkitFiles.RefreshFolders(); foreach (var moduleType in moduleTypes) { // Validate that each module has a corresponding found folder Assert.IsTrue(MixedRealityToolkitFiles.GetDirectories(moduleType).Any()); } }
public override void OnInspectorGUI() { var testGltfLoading = target as TestGltfLoading; base.OnInspectorGUI(); var path = testGltfLoading.AbsolutePath; bool needsCopy = !File.Exists(path) && Application.isEditor; if (needsCopy) { EditorGUILayout.HelpBox("glTF path was not discovered in the streaming assets folder. Please copy over files to test example scene", MessageType.Warning); } if (GUILayout.Button("Copy GLTF Directory to Streaming Assets")) { string modelPath = MixedRealityToolkitFiles.MapRelativeFolderPathToAbsolutePath(MixedRealityToolkitModuleType.Examples, GLTFModelsPath); DirectoryCopy(modelPath, Path.Combine(Application.streamingAssetsPath, "GltfModels")); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); Debug.Log("Copied glTF model files to Streaming Assets folder"); } }
private static string ResolveEditorWindowOptionsPath() { return(MixedRealityToolkitFiles.MapRelativeFilePathToAbsolutePath(EditorWindowOptionsPath)); }
public void TestRootAssetFolderResolution() { string resolvedPath = MixedRealityToolkitFiles.MapRelativeFilePathToAbsolutePath("Inspectors\\Data\\EditorWindowOptions.json"); Assert.IsNotNull(resolvedPath); }