Merge pull request #1086 from ousttrue/feature10/zip_extract

Feature10/zip extract
This commit is contained in:
PoChang007
2021-07-01 13:02:51 +09:00
committed by GitHub
12 changed files with 105 additions and 31 deletions

View File

@@ -1,5 +1,3 @@
using UnityEngine;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
@@ -10,14 +8,11 @@ using UnityEditor.Experimental.AssetImporters;
namespace UniGLTF
{
[ScriptedImporter(1, "glb")]
public class GlbScriptedImporter : ScriptedImporter
public class GlbScriptedImporter : GltfScriptedImporterBase
{
[SerializeField]
public ScriptedImporterAxes m_reverseAxis;
public override void OnImportAsset(AssetImportContext ctx)
{
ScriptedImporterImpl.Import(this, ctx, m_reverseAxis.ToAxes());
Import(this, ctx, m_reverseAxis.ToAxes());
}
}
}

View File

@@ -14,7 +14,7 @@ using UnityEditor.Experimental.AssetImporters;
namespace UniGLTF
{
[CustomEditor(typeof(GlbScriptedImporter))]
public class GlbScriptedImporterEditorGUI : RemapScriptedImporterEditorBase
public class GlbScriptedImporterEditor : RemapScriptedImporterEditorBase
{
GlbScriptedImporter m_importer;
GltfData m_data;

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 85bf14b48ed135743828ee49a830b1c6
guid: 2a09b107e404d4442adbc351d044536f
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,3 @@
using UnityEngine;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
@@ -10,14 +8,11 @@ using UnityEditor.Experimental.AssetImporters;
namespace UniGLTF
{
[ScriptedImporter(1, "gltf")]
public class GltfScriptedImporter : ScriptedImporter
public class GltfScriptedImporter : GltfScriptedImporterBase
{
[SerializeField]
public ScriptedImporterAxes m_reverseAxis = default;
public override void OnImportAsset(AssetImportContext ctx)
{
ScriptedImporterImpl.Import(this, ctx, m_reverseAxis.ToAxes());
Import(this, ctx, m_reverseAxis.ToAxes());
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Linq;
using UnityEngine;
using UnityEditor;
using System.Linq;
using VRMShaders;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
@@ -10,15 +11,21 @@ using UnityEditor.Experimental.AssetImporters;
namespace UniGLTF
{
public static class ScriptedImporterImpl
/// <summary>
/// ScriptedImporterImpl から改め
/// </summary>
public abstract class GltfScriptedImporterBase : ScriptedImporter
{
[SerializeField]
public ScriptedImporterAxes m_reverseAxis = default;
/// <summary>
/// glb をパースして、UnityObject化、さらにAsset化する
/// </summary>
/// <param name="scriptedImporter"></param>
/// <param name="context"></param>
/// <param name="reverseAxis"></param>
public static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, Axes reverseAxis)
protected static void Import(ScriptedImporter scriptedImporter, AssetImportContext context, Axes reverseAxis)
{
#if VRM_DEVELOP
Debug.Log("OnImportAsset to " + scriptedImporter.assetPath);
@@ -28,7 +35,7 @@ namespace UniGLTF
// Parse(parse glb, parser gltf json)
//
var data = new AmbiguousGltfFileParser(scriptedImporter.assetPath).Parse();
//
// Import(create unity objects)

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 706590752e82d004e99da97aff535f67
guid: ae1df0d1926e49f489c74bdf6ca369b5
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -14,7 +14,7 @@ using UnityEditor.Experimental.AssetImporters;
namespace UniGLTF
{
[CustomEditor(typeof(GltfScriptedImporter))]
public class GltfScriptedImporterEditorGUI : RemapScriptedImporterEditorBase
public class GltfScriptedImporterEditor : RemapScriptedImporterEditorBase
{
GltfScriptedImporter m_importer;
GltfData m_data;

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 16c69c858a1da5e4088d72a546a2963e
guid: 83c77bd3888dffa439b1feb6986b1b54
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -90,7 +90,7 @@ namespace UniGLTF
.ToDictionary(kv => kv.Item1, kv => kv.Item2)
;
var assetPath = UnityPath.FromFullpath(self.assetPath);
var assetPath = UnityPath.FromUnityPath(self.assetPath);
var dirName = textureDir(assetPath.Value); // $"{assetPath.FileNameWithoutExtension}.Textures";
TextureExtractor.ExtractTextures(
data,

View File

@@ -1,5 +1,3 @@
using UnityEngine;
using UnityEditor;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
@@ -12,14 +10,11 @@ namespace UniGLTF
#if UNIGLTF_ENABLE_ZIPARCHVIE_IMPORTER
[ScriptedImporter(1, "zip")]
#endif
public class ZipArchivedGltfScriptedImporter : ScriptedImporter
public class ZipArchivedGltfScriptedImporter : GltfScriptedImporterBase
{
[SerializeField]
public ScriptedImporterAxes m_reverseAxis = default;
public override void OnImportAsset(AssetImportContext ctx)
{
ScriptedImporterImpl.Import(this, ctx, m_reverseAxis.ToAxes());
Import(this, ctx, m_reverseAxis.ToAxes());
}
}
}

View File

@@ -0,0 +1,71 @@
using UnityEditor;
using UnityEngine;
using System.IO;
using System.Linq;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
using UnityEditor.Experimental.AssetImporters;
#endif
namespace UniGLTF
{
[CustomEditor(typeof(ZipArchivedGltfScriptedImporter))]
public class ZipArchivedGltfScriptedImporterEditor : RemapScriptedImporterEditorBase
{
ZipArchivedGltfScriptedImporter m_importer;
GltfData m_data;
RemapEditorMaterial m_materialEditor;
RemapEditorAnimation m_animationEditor;
public override void OnEnable()
{
base.OnEnable();
m_importer = target as ZipArchivedGltfScriptedImporter;
m_data = new AmbiguousGltfFileParser(m_importer.assetPath).Parse();
var materialGenerator = new GltfMaterialDescriptorGenerator();
var materialKeys = m_data.GLTF.materials.Select((_, i) => materialGenerator.Get(m_data, i).SubAssetKey);
var textureKeys = new GltfTextureDescriptorGenerator(m_data).Get().GetEnumerable().Select(x => x.SubAssetKey);
m_materialEditor = new RemapEditorMaterial(materialKeys.Concat(textureKeys), GetEditorMap, SetEditorMap);
m_animationEditor = new RemapEditorAnimation(AnimationImporterUtil.EnumerateSubAssetKeys(m_data.GLTF), GetEditorMap, SetEditorMap);
}
enum Tabs
{
Model,
Animation,
Materials,
}
static Tabs s_currentTab;
public override void OnInspectorGUI()
{
s_currentTab = MeshUtility.TabBar.OnGUI(s_currentTab);
GUILayout.Space(10);
switch (s_currentTab)
{
case Tabs.Model:
base.OnInspectorGUI();
break;
case Tabs.Animation:
m_animationEditor.OnGUI(m_importer, m_data);
RevertApplyRemapGUI(m_importer);
break;
case Tabs.Materials:
m_materialEditor.OnGUI(m_importer, m_data,
new GltfTextureDescriptorGenerator(m_data),
assetPath => $"{Path.GetFileNameWithoutExtension(assetPath)}.Textures",
assetPath => $"{Path.GetFileNameWithoutExtension(assetPath)}.Materials");
RevertApplyRemapGUI(m_importer);
break;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d2f9772e8a290e47812172c7fa6f34d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: