Skip to content

Commit b227941

Browse files
authored
Merge pull request #9658 from keveleigh/wrap-gltf-importer
Wrap glTF scripted importers with !MRTK_GLTF_IMPORTER_OFF
2 parents b3c4f8e + e05a52f commit b227941

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

Assets/MRTK/Core/Utilities/Editor/ScriptUtilities.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static class ScriptUtilities
2020
/// <param name="symbols">Array of symbols to define.</param>
2121
public static void AppendScriptingDefinitions(
2222
BuildTargetGroup targetGroup,
23-
string[] symbols)
23+
params string[] symbols)
2424
{
2525
if (symbols == null || symbols.Length == 0) { return; }
2626

@@ -38,7 +38,7 @@ public static void AppendScriptingDefinitions(
3838
/// <param name="symbols">Array of symbols to remove.</param>
3939
public static void RemoveScriptingDefinitions(
4040
BuildTargetGroup targetGroup,
41-
string[] symbols)
41+
params string[] symbols)
4242
{
4343
if (symbols == null || symbols.Length == 0) { return; }
4444

Assets/MRTK/Core/Utilities/Gltf/Serialization/Importers/GlbAssetImporter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
namespace Microsoft.MixedReality.Toolkit.Utilities.Gltf.Serialization.Editor
1111
{
12+
#if !MRTK_GLTF_IMPORTER_OFF
1213
[ScriptedImporter(1, "glb")]
14+
#endif // !MRTK_GLTF_IMPORTER_OFF
1315
public class GlbAssetImporter : ScriptedImporter
1416
{
1517
public override void OnImportAsset(AssetImportContext context)
1618
{
1719
GltfEditorImporter.OnImportGltfAsset(context);
1820
}
1921
}
20-
}
22+
}

Assets/MRTK/Core/Utilities/Gltf/Serialization/Importers/GltfAssetImporter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99

1010
namespace Microsoft.MixedReality.Toolkit.Utilities.Gltf.Serialization.Editor
1111
{
12+
#if !MRTK_GLTF_IMPORTER_OFF
1213
[ScriptedImporter(1, "gltf")]
14+
#endif // !MRTK_GLTF_IMPORTER_OFF
1315
public class GltfAssetImporter : ScriptedImporter
1416
{
1517
public override void OnImportAsset(AssetImportContext context)
1618
{
1719
GltfEditorImporter.OnImportGltfAsset(context);
1820
}
1921
}
20-
}
22+
}

Assets/MRTK/Core/Utilities/Gltf/Serialization/Importers/GltfEditorImporter.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
using Microsoft.MixedReality.Toolkit.Utilities.Editor;
45
using Microsoft.MixedReality.Toolkit.Utilities.Gltf.Schema;
56
using System.IO;
67
using UnityEditor;
@@ -16,6 +17,22 @@ namespace Microsoft.MixedReality.Toolkit.Utilities.Gltf.Serialization.Editor
1617
{
1718
public static class GltfEditorImporter
1819
{
20+
#if MRTK_GLTF_IMPORTER_OFF
21+
[MenuItem("Mixed Reality/Toolkit/Utilities/Enable MRTK glTF asset importer")]
22+
#else
23+
[MenuItem("Mixed Reality/Toolkit/Utilities/Disable MRTK glTF asset importer")]
24+
#endif
25+
private static void ReconcileGltfImporterDefine()
26+
{
27+
BuildTargetGroup group = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
28+
29+
#if MRTK_GLTF_IMPORTER_OFF
30+
ScriptUtilities.RemoveScriptingDefinitions(group, "MRTK_GLTF_IMPORTER_OFF");
31+
#else
32+
ScriptUtilities.AppendScriptingDefinitions(group, "MRTK_GLTF_IMPORTER_OFF");
33+
#endif
34+
}
35+
1936
public static async void OnImportGltfAsset(AssetImportContext context)
2037
{
2138
var importedObject = await GltfUtility.ImportGltfObjectFromPathAsync(context.assetPath);

0 commit comments

Comments
 (0)