Skip to content

Commit e265541

Browse files
author
David Kline
authored
Merge pull request #7288 from keveleigh/more-docs
Update FindFilesInAssets to only search AssetDatabase
2 parents abcf8fc + 0f54a9b commit e265541

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

Assets/MixedRealityToolkit.Providers/UnityAR/Editor/ConfigurationChecker/UnityARConfigurationChecker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static bool ReconcileArFoundationDefine()
5656
/// - If AR Foundation has been installed via the Unity Package Manager, add the appropriate assembly references
5757
/// - Unity 2018: Unity.XR.ARFoundation
5858
/// - Unity 2019 and newer: Unity.XR.ARFoundation, UnityEngine.SpatialTracking
59-
/// - If AR Foundation has been uninstalled, remove the assembly references.
59+
/// - If AR Foundation has been uninstalled, remove the assembly references.
6060
/// - Save the Microsoft.MixedReality.Toolkit.Providers.UnityAR.asmdef file
6161
/// This will result in Unity reloading the assembly with the appropriate dependencies.
6262
/// </remarks>

Assets/MixedRealityToolkit.Tests/EditModeTests/Core/MixedRealityToolkitFilesTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,16 @@ public IEnumerator TestRootAssetFolderResolution()
101101
Assert.IsNotNull(resolvedPath);
102102
}
103103

104+
/// <summary>
105+
/// Validates that FileUtilities.FindFilesInAssets can find this test script in the asset database.
106+
/// </summary>
107+
[Test]
108+
public void TestFileUtilitiesFindFilesInAssets()
109+
{
110+
FileInfo[] files = FileUtilities.FindFilesInAssets("MixedRealityToolkitFilesTests.cs");
111+
Assert.IsTrue(files.Length == 1);
112+
}
113+
104114
[TearDown]
105115
public void CleanupTests()
106116
{

Assets/MixedRealityToolkit/Utilities/Editor/FileUtilities.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using System.Collections.Generic;
45
using System.IO;
56
using UnityEditor;
67
using UnityEngine;
@@ -13,14 +14,35 @@ namespace Microsoft.MixedReality.Toolkit.Utilities.Editor
1314
public static class FileUtilities
1415
{
1516
/// <summary>
16-
/// Locates the files that match the specified name within the Assets folder (application data path) structure.
17+
/// Locates the files that match the specified name within the Assets folder structure.
1718
/// </summary>
1819
/// <param name="fileName">The name of the file to locate (ex: "TestFile.asmdef")</param>
20+
/// <param name="searchFullFileSystem">If true, searches the full application data path. If false, only searches Unity's known asset database.</param>
1921
/// <returns>Array of FileInfo objects representing the located file(s).</returns>
20-
public static FileInfo[] FindFilesInAssets(string fileName)
22+
public static FileInfo[] FindFilesInAssets(string fileName, bool searchFullFileSystem = false)
2123
{
22-
DirectoryInfo root = new DirectoryInfo(Application.dataPath);
23-
return FindFiles(fileName, root);
24+
if (searchFullFileSystem)
25+
{
26+
DirectoryInfo root = new DirectoryInfo(Application.dataPath);
27+
return FindFiles(fileName, root);
28+
}
29+
else
30+
{
31+
// FindAssets doesn't take a file extension
32+
string[] assetGuids = AssetDatabase.FindAssets(Path.GetFileNameWithoutExtension(fileName));
33+
List<FileInfo> fileInfos = new List<FileInfo>();
34+
for (int i = 0; i < assetGuids.Length; i++)
35+
{
36+
string assetPath = AssetDatabase.GUIDToAssetPath(assetGuids[i]);
37+
// Since this is an asset search without extension, some filenames may contain parts of other filenames.
38+
// Therefore, double check that the path actually contains the filename with extension.
39+
if (assetPath.Contains(fileName))
40+
{
41+
fileInfos.Add(new FileInfo(assetPath));
42+
}
43+
}
44+
return fileInfos.ToArray();
45+
}
2446
}
2547

2648
/// <summary>

Assets/MixedRealityToolkit/Utilities/ScriptingUtilities.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
3+
34
#if UNITY_EDITOR
4-
using UnityEngine;
5-
using UnityEditor;
6-
using System.IO;
75
using System;
8-
using System.Runtime.CompilerServices;
6+
using System.IO;
7+
using UnityEditor;
8+
using UnityEngine;
99

1010
namespace Microsoft.MixedReality.Toolkit.Utilities.Editor
1111
{
1212
/// <summary>
13-
/// A set of utilities to configure script compilation.
13+
/// A set of utilities to configure script compilation.
1414
/// </summary>
1515
[Obsolete("The ScriptingUtilities class is obsolete and will be removed from a future version of MRTK. Please use the ScriptUtilities class.")]
1616
public static class ScriptingUtilities
@@ -22,15 +22,15 @@ public static class ScriptingUtilities
2222
/// </summary>
2323
/// <param name="fileName">The name of an optional file locate before appending.</param>
2424
/// <returns>
25-
/// <param name="targetGroup">The build target group for which the sybmols are to be defined.</param>
25+
/// <param name="targetGroup">The build target group for which the symbols are to be defined.</param>
2626
/// <param name="symbols">Array of symbols to define.</param>
2727
/// <remarks>
2828
/// To always append the symbols, pass null (or the empty string) for the fileName parameter.
2929
/// </remarks>
3030
[Obsolete("ScriptingUtilties.AppendScriptingDefinitions is obsolete and will be removed from a future version of MRTK. Please use FileUtilities.FindFilesInAssets and ScriptUtilties.AppendScriptingDefinitions.")]
3131
public static void AppendScriptingDefinitions(
32-
string fileName,
33-
BuildTargetGroup targetGroup,
32+
string fileName,
33+
BuildTargetGroup targetGroup,
3434
string[] symbols)
3535
{
3636
// Note: Typically, obsolete methods are re-implemented using the replacement versions.
@@ -69,4 +69,4 @@ public static void AppendScriptingDefinitions(
6969
}
7070
}
7171
}
72-
#endif // UNITY_EDITOR
72+
#endif // UNITY_EDITOR

Documentation/Tools/HolographicRemoting.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ If you're running into conflicts or other issues due to the presence of the DotN
5353

5454
You can also temporarily remove the adapter to workaround your issue via the following steps:
5555

56-
1. In Unity, go to Window -> Package Manager and uninstall MSBuild for Unity
57-
1. Search for DotNetWinRT.dll in your assets list in Unity and either delete the DLL or delete the Plugins (MRTK 2.2 or earlier) or Dependencies (MRTK 2.3 or later) folder that contains it a few levels up. That should remove these conflicting namespaces, while keeping MRTK around
58-
1. If you run the MRTK Configurator again, make sure you don't re-enable MSBuild for Unity
56+
1. In Unity, go to Window -> Package Manager and uninstall MSBuild for Unity.
57+
1. Search for DotNetWinRT.dll in your assets list in Unity and either delete the DLL or delete the Plugins (MRTK 2.2 or earlier) or Dependencies (MRTK 2.3 or later) folder that contains it a few levels up. That should remove these conflicting namespaces, while keeping MRTK around.
58+
1. (Optional) Navigate to MixedRealityToolkit.Providers / WindowsMixedReality / Shared / DotNetAdapter in your file explorer (not Unity's Assets view) and delete the `.bin` and `.obj` folders. This removes the local cache of NuGet restored packages for DotNetWinRT.
59+
1. If you run the MRTK Configurator again, make sure you don't re-enable MSBuild for Unity.
5960

6061
## Connecting to the HoloLens
6162

0 commit comments

Comments
 (0)