GLBImporter.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #if HAVE_GLTFAST || HAVE_UNITYGLTF
  2. #define ANOTHER_IMPORTER_HAS_HIGHER_PRIORITY
  3. #endif
  4. #if !ANOTHER_IMPORTER_HAS_HIGHER_PRIORITY && !GLTFUTILITY_FORCE_DEFAULT_IMPORTER_OFF
  5. #define ENABLE_DEFAULT_GLB_IMPORTER
  6. #endif
  7. #if GLTFUTILITY_FORCE_DEFAULT_IMPORTER_ON
  8. #define ENABLE_DEFAULT_GLB_IMPORTER
  9. #endif
  10. using UnityEngine;
  11. #if !UNITY_2020_2_OR_NEWER
  12. using UnityEditor.Experimental.AssetImporters;
  13. #else
  14. using UnityEditor.AssetImporters;
  15. #endif
  16. namespace Siccity.GLTFUtility {
  17. #if ENABLE_DEFAULT_GLB_IMPORTER
  18. [ScriptedImporter(1, "glb")]
  19. #else
  20. [ScriptedImporter(2, null, overrideExts: new[] { "glb" })]
  21. #endif
  22. public class GLBImporter : GLTFImporter {
  23. public override void OnImportAsset(AssetImportContext ctx) {
  24. // Load asset
  25. AnimationClip[] animations;
  26. if (importSettings == null) importSettings = new ImportSettings();
  27. GameObject root = Importer.LoadFromFile(ctx.assetPath, importSettings, out animations, Format.GLB);
  28. // Save asset
  29. GLTFAssetUtility.SaveToAsset(root, animations, ctx, importSettings);
  30. }
  31. }
  32. }