diff --git a/Assets/UniGLTF/Editor/UniGLTF/AssetTextureUtil.cs b/Assets/UniGLTF/Editor/UniGLTF/AssetTextureUtil.cs
new file mode 100644
index 000000000..d22efde76
--- /dev/null
+++ b/Assets/UniGLTF/Editor/UniGLTF/AssetTextureUtil.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using UnityEditor;
+using UnityEngine;
+
+namespace UniGLTF
+{
+ public static class AssetTextureUtil
+ {
+ ///
+ /// TextureImporter.maxTextureSize が元のテクスチャーより小さいか否かの判定
+ ///
+ ///
+ ///
+ public static bool CopyIfMaxTextureSizeIsSmaller(Texture src)
+ {
+ var textureImporter = AssetImporter.GetAtPath(UnityPath.FromAsset(src).Value) as TextureImporter;
+
+ // private メソッド TextureImporter.GetWidthAndHeight を無理やり呼ぶ
+ var getSizeMethod = typeof(TextureImporter).GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance);
+ if (textureImporter != null && getSizeMethod != null)
+ {
+ var args = new object[2] { 0, 0 };
+ getSizeMethod.Invoke(textureImporter, args);
+ var originalWidth = (int)args[0];
+ var originalHeight = (int)args[1];
+ var originalSize = Mathf.Max(originalWidth, originalHeight);
+ if (textureImporter.maxTextureSize < originalSize)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ ///
+ /// 元の Asset が存在して、 TextureImporter に設定された画像サイズが小さくない
+ ///
+ ///
+ ///
+ ///
+ public static bool UseAsset(Texture texture)
+ {
+ if (texture != null && !string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(texture)))
+ {
+ if (CopyIfMaxTextureSizeIsSmaller(texture))
+ {
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/Assets/UniGLTF/Editor/UniGLTF/AssetTextureUtil.cs.meta b/Assets/UniGLTF/Editor/UniGLTF/AssetTextureUtil.cs.meta
new file mode 100644
index 000000000..003d5df03
--- /dev/null
+++ b/Assets/UniGLTF/Editor/UniGLTF/AssetTextureUtil.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6efbb66c1ac168848beead1fe3b16263
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/UniGLTF/Editor/UniGLTF/GltfExportWindow.cs b/Assets/UniGLTF/Editor/UniGLTF/GltfExportWindow.cs
index 2e60f932f..6ed78c1b1 100644
--- a/Assets/UniGLTF/Editor/UniGLTF/GltfExportWindow.cs
+++ b/Assets/UniGLTF/Editor/UniGLTF/GltfExportWindow.cs
@@ -35,7 +35,7 @@ namespace UniGLTF
using (var exporter = new gltfExporter(gltf, inverseAxis))
{
exporter.Prepare(go);
- exporter.Export(settings);
+ exporter.Export(settings, AssetTextureUtil.UseAsset);
}
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs
index ab9a3bedd..b31901418 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs
@@ -1,7 +1,7 @@
-using System;
-using System.Linq;
+using System.Linq;
using UniGLTF.UniUnlit;
using UnityEngine;
+using VRMShaders;
namespace UniGLTF
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs
index f126e8262..086bc7f6b 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/TextureIO/TextureExporter.cs
@@ -1,13 +1,9 @@
using System;
using System.Collections.Generic;
using UnityEngine;
-using System.Reflection;
-using VRMShaders;
-#if UNITY_EDITOR
-using UnityEditor;
-#endif
-namespace UniGLTF
+
+namespace VRMShaders
{
///
/// glTF にエクスポートする Texture2D を蓄えて index を確定させる。
@@ -15,12 +11,29 @@ namespace UniGLTF
///
public class TextureExporter
{
+ Func m_useAsset;
+
+ public TextureExporter(Func useAsset)
+ {
+ m_useAsset = useAsset;
+ }
+
+ public enum ConvertTypes
+ {
+ // 無変換
+ None,
+ // Unity Standard様式 から glTF PBR様式への変換
+ OcclusionMetallicRoughness,
+ // Assetを使うときはそのバイト列を無変換で、それ以外は DXT5nm 形式からのデコードを行う
+ Normal,
+ }
+
struct ExportKey
{
public readonly Texture Src;
- public readonly glTFTextureTypes TextureType;
+ public readonly ConvertTypes TextureType;
- public ExportKey(Texture src, glTFTextureTypes type)
+ public ExportKey(Texture src, ConvertTypes type)
{
if (src == null)
{
@@ -45,7 +58,7 @@ namespace UniGLTF
///
///
///
- public int GetTextureIndex(Texture src, glTFTextureTypes textureType)
+ public int GetTextureIndex(Texture src, ConvertTypes textureType)
{
if (src == null)
{
@@ -54,53 +67,6 @@ namespace UniGLTF
return m_exportMap[new ExportKey(src, textureType)];
}
- ///
- /// TextureImporter.maxTextureSize が元のテクスチャーより小さいか否かの判定
- ///
- ///
- ///
- static bool CopyIfMaxTextureSizeIsSmaller(Texture src)
- {
-#if UNITY_EDITOR
- var textureImporter = AssetImporter.GetAtPath(UnityPath.FromAsset(src).Value) as TextureImporter;
- var getSizeMethod = typeof(TextureImporter).GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance);
- if (textureImporter != null && getSizeMethod != null)
- {
- var args = new object[2] { 0, 0 };
- getSizeMethod.Invoke(textureImporter, args);
- var originalWidth = (int)args[0];
- var originalHeight = (int)args[1];
- var originalSize = Mathf.Max(originalWidth, originalHeight);
- if (textureImporter.maxTextureSize < originalSize)
- {
- return true;
- }
- }
-#endif
- return false;
- }
-
- ///
- /// 元の Asset が存在して、 TextureImporter に設定された画像サイズが小さくない
- ///
- ///
- ///
- ///
- static bool UseAsset(Texture2D texture2D)
- {
-#if UNITY_EDITOR
- if (texture2D != null && !string.IsNullOrEmpty(UnityEditor.AssetDatabase.GetAssetPath(texture2D)))
- {
- if (CopyIfMaxTextureSizeIsSmaller(texture2D))
- {
- return false;
- }
- return true;
- }
-#endif
- return false;
- }
-
///
/// sRGBなテクスチャーを処理し、index を確定させる
///
@@ -114,7 +80,7 @@ namespace UniGLTF
}
// cache
- if (m_exportMap.TryGetValue(new ExportKey(src, glTFTextureTypes.SRGB), out var index))
+ if (m_exportMap.TryGetValue(new ExportKey(src, ConvertTypes.None), out var index))
{
return index;
}
@@ -122,7 +88,7 @@ namespace UniGLTF
// get Texture2D
index = Exported.Count;
var texture2D = src as Texture2D;
- if (UseAsset(texture2D))
+ if (m_useAsset(texture2D))
{
// do nothing
}
@@ -131,7 +97,7 @@ namespace UniGLTF
texture2D = TextureConverter.CopyTexture(src, TextureImportTypes.sRGB, null);
}
Exported.Add(texture2D);
- m_exportMap.Add(new ExportKey(src, glTFTextureTypes.SRGB), index);
+ m_exportMap.Add(new ExportKey(src, ConvertTypes.None), index);
return index;
}
@@ -161,11 +127,11 @@ namespace UniGLTF
}
// cache
- if (metallicSmoothTexture != null && m_exportMap.TryGetValue(new ExportKey(metallicSmoothTexture, glTFTextureTypes.OcclusionMetallicRoughness), out var index))
+ if (metallicSmoothTexture != null && m_exportMap.TryGetValue(new ExportKey(metallicSmoothTexture, ConvertTypes.OcclusionMetallicRoughness), out var index))
{
return index;
}
- if (occlusionTexture != null && m_exportMap.TryGetValue(new ExportKey(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness), out index))
+ if (occlusionTexture != null && m_exportMap.TryGetValue(new ExportKey(occlusionTexture, ConvertTypes.OcclusionMetallicRoughness), out index))
{
return index;
}
@@ -179,11 +145,11 @@ namespace UniGLTF
Exported.Add(texture2D);
if (metallicSmoothTexture != null)
{
- m_exportMap.Add(new ExportKey(metallicSmoothTexture, glTFTextureTypes.OcclusionMetallicRoughness), index);
+ m_exportMap.Add(new ExportKey(metallicSmoothTexture, ConvertTypes.OcclusionMetallicRoughness), index);
}
if (occlusionTexture != null && occlusionTexture != metallicSmoothTexture)
{
- m_exportMap.Add(new ExportKey(occlusionTexture, glTFTextureTypes.OcclusionMetallicRoughness), index);
+ m_exportMap.Add(new ExportKey(occlusionTexture, ConvertTypes.OcclusionMetallicRoughness), index);
}
return index;
@@ -202,7 +168,7 @@ namespace UniGLTF
}
// cache
- if (m_exportMap.TryGetValue(new ExportKey(src, glTFTextureTypes.Normal), out var index))
+ if (m_exportMap.TryGetValue(new ExportKey(src, ConvertTypes.Normal), out var index))
{
return index;
}
@@ -210,7 +176,7 @@ namespace UniGLTF
// get Texture2D
index = Exported.Count;
var texture2D = src as Texture2D;
- if (UseAsset(texture2D))
+ if (m_useAsset(texture2D))
{
// EditorAsset を使うので変換不要
}
@@ -221,7 +187,7 @@ namespace UniGLTF
}
Exported.Add(texture2D);
- m_exportMap.Add(new ExportKey(src, glTFTextureTypes.Normal), index);
+ m_exportMap.Add(new ExportKey(src, ConvertTypes.Normal), index);
return index;
}
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
index 5aa7c151e..1bdb2f060 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
-
+using VRMShaders;
namespace UniGLTF
{
@@ -173,7 +173,7 @@ namespace UniGLTF
}
- public virtual void Export(MeshExportSettings meshExportSettings)
+ public virtual void Export(MeshExportSettings meshExportSettings, Func useAsset)
{
var bytesBuffer = new ArrayByteBuffer(new byte[50 * 1024 * 1024]);
var bufferIndex = glTF.AddBuffer(bytesBuffer);
@@ -185,7 +185,7 @@ namespace UniGLTF
#region Materials and Textures
Materials = Nodes.SelectMany(x => x.GetSharedMaterials()).Where(x => x != null).Distinct().ToList();
- TextureManager = new TextureExporter();
+ TextureManager = new TextureExporter(useAsset);
var materialExporter = CreateMaterialExporter();
glTF.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureManager)).ToList();
diff --git a/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs b/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs
index ebbc590e3..039c67c9c 100644
--- a/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs
+++ b/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs
@@ -18,7 +18,7 @@ namespace UniGLTF
filterMode = FilterMode.Bilinear,
};
- var textureManager = new TextureExporter();
+ var textureManager = new TextureExporter(AssetTextureUtil.UseAsset);
var srcMaterial = new Material(Shader.Find("Standard"));
var offset = new Vector2(0.3f, 0.2f);
@@ -242,7 +242,7 @@ namespace UniGLTF
material.SetColor("_EmissionColor", new Color(0, 1, 2, 1));
material.EnableKeyword("_EMISSION");
var materialExporter = new MaterialExporter();
- var textureExportManager = new TextureExporter();
+ var textureExportManager = new TextureExporter(AssetTextureUtil.UseAsset);
var gltfMaterial = materialExporter.ExportMaterial(material, textureExportManager);
Assert.AreEqual(gltfMaterial.emissiveFactor, new float[] { 0, 0.5f, 1 });
diff --git a/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs
index 91c960e2a..4371fcdd7 100644
--- a/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs
+++ b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs
@@ -15,7 +15,7 @@ namespace UniGLTF
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Trilinear,
};
- var textureManager = new TextureExporter();
+ var textureManager = new TextureExporter(AssetTextureUtil.UseAsset);
var material = new Material(Shader.Find("Standard"));
material.mainTexture = tex0;
@@ -58,16 +58,16 @@ namespace UniGLTF
var occlusion = new Texture2D(4, 4, TextureFormat.ARGB32, false, true);
{
- var exporter = new TextureExporter();
+ var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
Assert.AreEqual(-1, exporter.ExportMetallicSmoothnessOcclusion(null, 0, null));
}
{
- var exporter = new TextureExporter();
+ var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(null, 0, occlusion));
Assert.AreEqual(1, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, null));
}
{
- var exporter = new TextureExporter();
+ var exporter = new TextureExporter(AssetTextureUtil.UseAsset);
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, occlusion));
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(null, 0, occlusion));
Assert.AreEqual(0, exporter.ExportMetallicSmoothnessOcclusion(metallic, 0, null));
diff --git a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs
index 9cf2512a1..cd73aa0c3 100644
--- a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs
+++ b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs
@@ -106,7 +106,7 @@ namespace UniGLTF
using (var exporter = new gltfExporter(gltf))
{
exporter.Prepare(go);
- exporter.Export(MeshExportSettings.Default);
+ exporter.Export(MeshExportSettings.Default, AssetTextureUtil.UseAsset);
// remove empty buffer
gltf.buffers.Clear();
@@ -298,7 +298,7 @@ namespace UniGLTF
using (var exporter = new gltfExporter(gltf))
{
exporter.Prepare(CreateSimpleScene());
- exporter.Export(MeshExportSettings.Default);
+ exporter.Export(MeshExportSettings.Default, AssetTextureUtil.UseAsset);
}
var expected = gltf.ToJson().ParseAsJson();
@@ -534,7 +534,7 @@ namespace UniGLTF
using (var exporter = new gltfExporter(gltf))
{
exporter.Prepare(go);
- exporter.Export(UniGLTF.MeshExportSettings.Default);
+ exporter.Export(UniGLTF.MeshExportSettings.Default, AssetTextureUtil.UseAsset);
json = gltf.ToJson();
}
diff --git a/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef b/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef
index 31fbd23fc..fad13ad55 100644
--- a/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef
+++ b/Assets/VRM.Samples/Editor/Tests/VRM.Samples.Editor.Tests.asmdef
@@ -6,7 +6,9 @@
"MeshUtility",
"UniGLTF",
"UniVRM.Editor",
- "VRM.Tests"
+ "VRM.Tests",
+ "VRMShaders",
+ "UniGLTF.Editor"
],
"optionalUnityReferences": [
"TestAssemblies"
diff --git a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs
index e484e372f..ee23d0e99 100644
--- a/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs
+++ b/Assets/VRM.Samples/Editor/Tests/VRMImportExportTests.cs
@@ -169,7 +169,7 @@ namespace VRM.Samples
*/
importedJson.RemoveValue(Utf8String.From("/bufferViews/*/byteStride"));
- var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, context.Root);
+ var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, context.Root, AssetTextureUtil.UseAsset);
// TODO: Check contents in JSON
/*var exportJson = */
diff --git a/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs b/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs
index cf75d926a..7c98c6829 100644
--- a/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs
+++ b/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs
@@ -1,6 +1,7 @@
using NUnit.Framework;
+using UniGLTF;
using UnityEngine;
-
+using VRMShaders;
namespace VRM.Samples
{
@@ -10,7 +11,7 @@ namespace VRM.Samples
{
var material = Resources.Load(resourceName);
var exporter = new VRMMaterialExporter();
- var textureManager = new UniGLTF.TextureExporter();
+ var textureManager = new TextureExporter(AssetTextureUtil.UseAsset);
var exported = exporter.ExportMaterial(material, textureManager);
// parse glTFExtensionExport to glTFExtensionImport
diff --git a/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs b/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs
index 16119365e..23d5ad165 100644
--- a/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs
+++ b/Assets/VRM.Samples/Scripts/VRMRuntimeExporter.cs
@@ -95,7 +95,7 @@ namespace VRM.Samples
return;
}
- var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, m_model);
+ var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, m_model, _ => false);
var bytes = vrm.ToGlbBytes();
File.WriteAllBytes(path, bytes);
Debug.LogFormat("export to {0}", path);
diff --git a/Assets/VRM.Samples/VRM.Samples.asmdef b/Assets/VRM.Samples/VRM.Samples.asmdef
index 70aae1594..de2c46ae4 100644
--- a/Assets/VRM.Samples/VRM.Samples.asmdef
+++ b/Assets/VRM.Samples/VRM.Samples.asmdef
@@ -3,7 +3,8 @@
"references": [
"VRM",
"UniHumanoid",
- "UniGLTF"
+ "UniGLTF",
+ "VRMShaders"
],
"optionalUnityReferences": [],
"includePlatforms": [],
diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs
index 96e236ab0..40c5e8cdc 100644
--- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs
+++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs
@@ -224,7 +224,7 @@ namespace VRM
using (var exporter = new VRMExporter(gltf))
{
exporter.Prepare(target);
- exporter.Export(settings.MeshExportSettings);
+ exporter.Export(settings.MeshExportSettings, AssetTextureUtil.UseAsset);
}
var bytes = gltf.ToGlbBytes();
File.WriteAllBytes(path, bytes);
diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs
index c4d5c80bb..a1a5ce748 100644
--- a/Assets/VRM/Runtime/IO/VRMExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMExporter.cs
@@ -14,13 +14,13 @@ namespace VRM
return new VRMMaterialExporter();
}
- public static glTF Export(MeshExportSettings configuration, GameObject go)
+ public static glTF Export(MeshExportSettings configuration, GameObject go, Func useAsset)
{
var gltf = new glTF();
using (var exporter = new VRMExporter(gltf))
{
exporter.Prepare(go);
- exporter.Export(configuration);
+ exporter.Export(configuration, useAsset);
}
return gltf;
}
diff --git a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
index 0b49c6b90..22c3ab11b 100644
--- a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
@@ -4,7 +4,7 @@ using System.Linq;
using UniGLTF;
using UniGLTF.ShaderPropExporter;
using UnityEngine;
-
+using VRMShaders;
namespace VRM
{
diff --git a/Assets/VRM/Tests/MToonTest.cs b/Assets/VRM/Tests/MToonTest.cs
index b8326d7e0..86d79422d 100644
--- a/Assets/VRM/Tests/MToonTest.cs
+++ b/Assets/VRM/Tests/MToonTest.cs
@@ -1,6 +1,7 @@
using NUnit.Framework;
using UniGLTF;
using UnityEngine;
+using VRMShaders;
namespace VRM
{
@@ -15,7 +16,7 @@ namespace VRM
filterMode = FilterMode.Bilinear,
};
- var textureManager = new TextureExporter();
+ var textureManager = new TextureExporter(AssetTextureUtil.UseAsset);
var srcMaterial = new Material(Shader.Find("VRM/MToon"));
var offset = new Vector2(0.3f, 0.2f);
diff --git a/Assets/VRM/Tests/VRM.Tests.asmdef b/Assets/VRM/Tests/VRM.Tests.asmdef
index 6f70ecbf9..36d8d3e11 100644
--- a/Assets/VRM/Tests/VRM.Tests.asmdef
+++ b/Assets/VRM/Tests/VRM.Tests.asmdef
@@ -5,7 +5,8 @@
"UniGLTF",
"MeshUtility",
"MeshUtility.Editor",
- "VRMShaders"
+ "VRMShaders",
+ "UniGLTF.Editor"
],
"optionalUnityReferences": [
"TestAssemblies"
diff --git a/Assets/VRM/Tests/VRMLoadTests.cs b/Assets/VRM/Tests/VRMLoadTests.cs
index 49173e7f3..ce4d2fce5 100644
--- a/Assets/VRM/Tests/VRMLoadTests.cs
+++ b/Assets/VRM/Tests/VRMLoadTests.cs
@@ -105,7 +105,7 @@ namespace VRM
try
{
// export
- var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, go);
+ var vrm = VRMExporter.Export(UniGLTF.MeshExportSettings.Default, go, AssetTextureUtil.UseAsset);
// re import
if (vrm != null)
diff --git a/Assets/VRM10/Runtime/Migration/MigrationMToon.cs b/Assets/VRM10/Runtime/Migration/MigrationMToon.cs
index f500548cc..1c55b1580 100644
--- a/Assets/VRM10/Runtime/Migration/MigrationMToon.cs
+++ b/Assets/VRM10/Runtime/Migration/MigrationMToon.cs
@@ -124,7 +124,10 @@ namespace UniVRM10
break;
default:
- throw new NotImplementedException($"{kv.Key}: {kv.Value}");
+#if VRM_DEVELOP
+ Debug.LogWarning($"vectorProperties: {kv.Key}: {kv.Value}");
+#endif
+ break;
}
}
@@ -225,7 +228,10 @@ namespace UniVRM10
break;
default:
- throw new NotImplementedException($"floatProperties: {kv.Key} is unknown");
+#if VRM_DEVELOP
+ Debug.LogWarning($"floatProperties: {kv.Key} is unknown");
+#endif
+ break;
}
}
@@ -247,7 +253,10 @@ namespace UniVRM10
case "_OutlineWidthTexture": map.OutlineWidthTexture = index; break;
case "_UvAnimMaskTexture": map.UvAnimMaskTexture = index; break;
default:
- throw new NotImplementedException($"textureProperties: {kv.Key} is unknown");
+#if VRM_DEVELOP
+ Debug.LogWarning($"textureProperties: {kv.Key} is unknown");
+#endif
+ break;
}
}
@@ -313,7 +322,10 @@ namespace UniVRM10
{
index = mtoon.TextureIndexMap.MainTex.Value
};
- var value = mtoon.OffsetScale["_MainTex"];
+ if (!mtoon.OffsetScale.TryGetValue("_MainTex", out float[] value))
+ {
+ value = new float[] { 0, 0, 1, 1 };
+ }
glTF_KHR_texture_transform.Serialize(
gltfMaterial.pbrMetallicRoughness.baseColorTexture,
(value[0], value[1]),