Skip to content

Commit

Permalink
Increase editor import compatibility between different glTF packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Mar 16, 2022
1 parent 3dbd862 commit 09cfa1d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Scripts/Editor/GLBImporter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#if HAVE_GLTFAST || HAVE_UNITYGLTF
#define ANOTHER_IMPORTER_HAS_HIGHER_PRIORITY
#endif

#if !ANOTHER_IMPORTER_HAS_HIGHER_PRIORITY && !GLTFUTILITY_FORCE_DEFAULT_IMPORTER_OFF
#define ENABLE_DEFAULT_GLB_IMPORTER
#endif
#if GLTFUTILITY_FORCE_DEFAULT_IMPORTER_ON
#define ENABLE_DEFAULT_GLB_IMPORTER
#endif

using UnityEngine;
#if !UNITY_2020_2_OR_NEWER
using UnityEditor.Experimental.AssetImporters;
Expand All @@ -6,7 +17,11 @@
#endif

namespace Siccity.GLTFUtility {
#if ENABLE_DEFAULT_GLB_IMPORTER
[ScriptedImporter(1, "glb")]
#else
[ScriptedImporter(2, null, overrideExts: new[] { "glb" })]
#endif
public class GLBImporter : GLTFImporter {

public override void OnImportAsset(AssetImportContext ctx) {
Expand Down
16 changes: 15 additions & 1 deletion Scripts/Editor/GLTFImporter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
using UnityEditor;
#if HAVE_GLTFAST || HAVE_UNITYGLTF
#define ANOTHER_IMPORTER_HAS_HIGHER_PRIORITY
#endif

#if !ANOTHER_IMPORTER_HAS_HIGHER_PRIORITY && !GLTFUTILITY_FORCE_DEFAULT_IMPORTER_OFF
#define ENABLE_DEFAULT_GLB_IMPORTER
#endif
#if GLTFUTILITY_FORCE_DEFAULT_IMPORTER_ON
#define ENABLE_DEFAULT_GLB_IMPORTER
#endif

#if !UNITY_2020_2_OR_NEWER
using UnityEditor.Experimental.AssetImporters;
#else
Expand All @@ -7,7 +17,11 @@
using UnityEngine;

namespace Siccity.GLTFUtility {
#if ENABLE_DEFAULT_GLB_IMPORTER
[ScriptedImporter(1, "gltf")]
#else
[ScriptedImporter(1, null, overrideExts: new[] { "gltf" })]
#endif
public class GLTFImporter : ScriptedImporter {

public ImportSettings importSettings;
Expand Down
14 changes: 13 additions & 1 deletion Scripts/Editor/GLTFUtility.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,17 @@
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
"allowUnsafeCode": false,
"versionDefines": [
{
"name": "com.atteneder.gltfast",
"expression": "3.0.0",
"define": "HAVE_GLTFAST"
},
{
"name": "org.khronos.unitygltf",
"expression": "0.0.0",
"define": "HAVE_UNITYGLTF"
}
]
}

0 comments on commit 09cfa1d

Please sign in to comment.