From d90179a72046f8b4ca2eb4a2c48a135bcacf2133 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 29 Jun 2021 15:53:53 +0900 Subject: [PATCH] experimental zip archive importer --- .../ZipArchivedGltfScriptedImporter.cs | 25 +++++++++++++++++++ .../ZipArchivedGltfScriptedImporter.cs.meta | 11 ++++++++ .../Editor/UniGLTF/UniGLTFPreference.cs | 6 +++++ 3 files changed, 42 insertions(+) create mode 100644 Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs create mode 100644 Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs.meta diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs new file mode 100644 index 000000000..af7819a75 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using UnityEditor; +#if UNITY_2020_2_OR_NEWER +using UnityEditor.AssetImporters; +#else +using UnityEditor.Experimental.AssetImporters; +#endif + + +namespace UniGLTF +{ +#if UNIGLTF_ENABLE_ZIPARCHVIE_IMPORTER + [ScriptedImporter(1, "zip")] +#endif + public class ZipArchivedGltfScriptedImporter : ScriptedImporter + { + [SerializeField] + public ScriptedImporterAxes m_reverseAxis = default; + + public override void OnImportAsset(AssetImportContext ctx) + { + ScriptedImporterImpl.Import(this, ctx, m_reverseAxis.ToAxes()); + } + } +} diff --git a/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs.meta new file mode 100644 index 000000000..5379af092 --- /dev/null +++ b/Assets/UniGLTF/Editor/UniGLTF/ScriptedImporter/ZipArchivedGltfScriptedImporter.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8e13aa2d6ae3bf843aaca5298bb4d26c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs b/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs index 6a5f66cfc..2906a996a 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/UniGLTFPreference.cs @@ -11,6 +11,8 @@ namespace UniGLTF { public static class UniGLTFPreference { + public const string UNIGLTF_ENABLE_ZIPARCHVIE_IMPORTER = "UNIGLTF_ENABLE_ZIPARCHVIE_IMPORTER"; + static IEnumerable GetReimportPaths() { String[] guids = AssetDatabase.FindAssets("t:GameObject", null); @@ -68,6 +70,10 @@ namespace UniGLTF AssetDatabase.ImportAsset(path, default); } } + + // zip + UniGLTF.UniGLTFPreference.ToggleSymbol("Enable zip importer that contains gltf", UNIGLTF_ENABLE_ZIPARCHVIE_IMPORTER); + EditorGUILayout.HelpBox("This is `.zip` extension importer", MessageType.Warning); } const string AXIS_KEY = "UNIGLTF_IO_AXIS";