diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs
index 44ad11029..451f8fddf 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MaterialIO/MaterialExporter.cs
@@ -15,12 +15,12 @@ namespace UniGLTF
public interface IMaterialExporter
{
- glTFMaterial ExportMaterial(Material m, TextureExporter textureExporter);
+ glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter);
}
public class MaterialExporter : IMaterialExporter
{
- public virtual glTFMaterial ExportMaterial(Material m, TextureExporter textureExporter)
+ public virtual glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter)
{
var material = CreateMaterial(m);
@@ -34,7 +34,7 @@ namespace UniGLTF
return material;
}
- static void Export_Color(Material m, TextureExporter textureManager, glTFMaterial material)
+ static void Export_Color(Material m, ITextureExporter textureManager, glTFMaterial material)
{
if (m.HasProperty("_Color"))
{
@@ -60,9 +60,9 @@ namespace UniGLTF
/// Occlusion, Metallic, Roughness
///
///
- ///
+ ///
///
- static void Export_OcclusionMetallicRoughness(Material m, TextureExporter textureManager, glTFMaterial material)
+ static void Export_OcclusionMetallicRoughness(Material m, ITextureExporter textureExporter, glTFMaterial material)
{
Texture metallicSmoothTexture = default;
float smoothness = 1.0f;
@@ -88,7 +88,7 @@ namespace UniGLTF
}
}
- int index = textureManager.ExportMetallicSmoothnessOcclusion(metallicSmoothTexture, smoothness, occlusionTexture);
+ int index = textureExporter.ExportMetallicSmoothnessOcclusion(metallicSmoothTexture, smoothness, occlusionTexture);
if (index != -1 && metallicSmoothTexture != null)
{
@@ -127,11 +127,11 @@ namespace UniGLTF
}
}
- static void Export_Normal(Material m, TextureExporter textureManager, glTFMaterial material)
+ static void Export_Normal(Material m, ITextureExporter textureExporter, glTFMaterial material)
{
if (m.HasProperty("_BumpMap"))
{
- var index = textureManager.ExportNormal(m.GetTexture("_BumpMap"));
+ var index = textureExporter.ExportNormal(m.GetTexture("_BumpMap"));
if (index != -1)
{
material.normalTexture = new glTFMaterialNormalTextureInfo()
@@ -149,7 +149,7 @@ namespace UniGLTF
}
}
- static void Export_Emission(Material m, TextureExporter textureManager, glTFMaterial material)
+ static void Export_Emission(Material m, ITextureExporter textureExporter, glTFMaterial material)
{
if (m.IsKeywordEnabled("_EMISSION") == false)
return;
@@ -166,7 +166,7 @@ namespace UniGLTF
if (m.HasProperty("_EmissionMap"))
{
- var index = textureManager.ExportSRGB(m.GetTexture("_EmissionMap"));
+ var index = textureExporter.ExportSRGB(m.GetTexture("_EmissionMap"));
if (index != -1)
{
material.emissiveTexture = new glTFMaterialEmissiveTextureInfo()
diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
index e6dc21271..3fabfb438 100644
--- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
+++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs
@@ -43,7 +43,11 @@ namespace UniGLTF
private set;
}
- public TextureExporter TextureManager;
+ public TextureExporter TextureExporter
+ {
+ get;
+ private set;
+ }
protected virtual IMaterialExporter CreateMaterialExporter()
{
@@ -238,10 +242,10 @@ namespace UniGLTF
#region Materials and Textures
Materials = uniqueUnityMeshes.SelectMany(x => x.Renderer.sharedMaterials).Where(x => x != null).Distinct().ToList();
- TextureManager = new TextureExporter(textureSerializer);
+ TextureExporter = new TextureExporter(textureSerializer);
var materialExporter = CreateMaterialExporter();
- glTF.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureManager)).ToList();
+ glTF.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureExporter)).ToList();
#endregion
#region Meshes
@@ -360,9 +364,9 @@ namespace UniGLTF
ExportExtensions(textureSerializer);
// Extension で Texture が増える場合があるので最後に呼ぶ
- for (int i = 0; i < TextureManager.Exported.Count; ++i)
+ for (int i = 0; i < TextureExporter.Exported.Count; ++i)
{
- var (unityTexture, colorSpace) = TextureManager.Exported[i];
+ var (unityTexture, colorSpace) = TextureExporter.Exported[i];
glTF.PushGltfTexture(bufferIndex, unityTexture, colorSpace, textureSerializer);
}
}
diff --git a/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs b/Assets/UniGLTF/Tests/UniGLTF/MaterialTests.cs
index 67f11aa27..88d0e8508 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(new EditorTextureSerializer());
+ var textureExporter = new TextureExporter(new EditorTextureSerializer());
var srcMaterial = new Material(Shader.Find("Standard"));
var offset = new Vector2(0.3f, 0.2f);
@@ -29,7 +29,7 @@ namespace UniGLTF
srcMaterial.mainTextureScale = scale;
var materialExporter = new MaterialExporter();
- var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureManager);
+ var gltfMaterial = materialExporter.ExportMaterial(srcMaterial, textureExporter);
gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions = gltfMaterial.pbrMetallicRoughness.baseColorTexture.extensions.Deserialize();
Assert.IsTrue(glTF_KHR_texture_transform.TryGet(gltfMaterial.pbrMetallicRoughness.baseColorTexture, out glTF_KHR_texture_transform t));
@@ -242,8 +242,8 @@ namespace UniGLTF
material.SetColor("_EmissionColor", new Color(0, 1, 2, 1));
material.EnableKeyword("_EMISSION");
var materialExporter = new MaterialExporter();
- var textureExportManager = new TextureExporter(new EditorTextureSerializer());
- var gltfMaterial = materialExporter.ExportMaterial(material, textureExportManager);
+ var textureExporter = new TextureExporter(new EditorTextureSerializer());
+ var gltfMaterial = materialExporter.ExportMaterial(material, textureExporter);
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 f8dfb46ed..f18c6704d 100644
--- a/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs
+++ b/Assets/UniGLTF/Tests/UniGLTF/TextureTests.cs
@@ -18,15 +18,15 @@ namespace UniGLTF
wrapMode = TextureWrapMode.Clamp,
filterMode = FilterMode.Trilinear,
};
- var textureManager = new TextureExporter(new EditorTextureSerializer());
+ var textureExporter = new TextureExporter(new EditorTextureSerializer());
var material = new Material(Shader.Find("Standard"));
material.mainTexture = tex0;
var materialExporter = new MaterialExporter();
- materialExporter.ExportMaterial(material, textureManager);
+ materialExporter.ExportMaterial(material, textureExporter);
- var (convTex0, colorSpace) = textureManager.Exported[0];
+ var (convTex0, colorSpace) = textureExporter.Exported[0];
var sampler = TextureSamplerUtil.Export(convTex0);
Assert.AreEqual(glWrap.CLAMP_TO_EDGE, sampler.wrapS);
diff --git a/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs b/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs
index 3dc99c542..bfa2ee0b7 100644
--- a/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs
+++ b/Assets/VRM.Samples/Editor/Tests/VRMMaterialTests.cs
@@ -11,8 +11,8 @@ namespace VRM.Samples
{
var material = Resources.Load(resourceName);
var exporter = new VRMMaterialExporter();
- var textureManager = new TextureExporter(new EditorTextureSerializer());
- var exported = exporter.ExportMaterial(material, textureManager);
+ var textureExporter = new TextureExporter(new EditorTextureSerializer());
+ var exported = exporter.ExportMaterial(material, textureExporter);
// parse glTFExtensionExport to glTFExtensionImport
exported.extensions = exported.extensions.Deserialize();
diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs
index 3089ee051..c819f500f 100644
--- a/Assets/VRM/Runtime/IO/VRMExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMExporter.cs
@@ -136,7 +136,7 @@ namespace VRM
VRM.meta.title = meta.Title;
if (meta.Thumbnail != null)
{
- VRM.meta.texture = TextureManager.ExportSRGB(meta.Thumbnail);
+ VRM.meta.texture = TextureExporter.ExportSRGB(meta.Thumbnail);
}
// ussage permission
@@ -199,7 +199,7 @@ namespace VRM
// materials
foreach (var m in Materials)
{
- VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager));
+ VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureExporter));
}
// Serialize VRM
diff --git a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
index 7b65783d2..5f7e056b4 100644
--- a/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
+++ b/Assets/VRM/Runtime/IO/VRMMaterialExporter.cs
@@ -126,7 +126,7 @@ namespace VRM
// "Queue",
};
- public static glTF_VRM_Material CreateFromMaterial(Material m, TextureExporter textureExporter)
+ public static glTF_VRM_Material CreateFromMaterial(Material m, ITextureExporter textureExporter)
{
var material = new glTF_VRM_Material
{
diff --git a/Assets/VRM/Tests/MToonTest.cs b/Assets/VRM/Tests/MToonTest.cs
index 73686c489..c0f52b0e3 100644
--- a/Assets/VRM/Tests/MToonTest.cs
+++ b/Assets/VRM/Tests/MToonTest.cs
@@ -18,7 +18,7 @@ namespace VRM
filterMode = FilterMode.Bilinear,
};
- var textureManager = new TextureExporter(new EditorTextureSerializer());
+ var textureExporter = new TextureExporter(new EditorTextureSerializer());
var srcMaterial = new Material(Shader.Find("VRM/MToon"));
var offset = new Vector2(0.3f, 0.2f);
@@ -29,7 +29,7 @@ namespace VRM
srcMaterial.mainTextureScale = scale;
var materialExporter = new VRMMaterialExporter();
- var vrmMaterial = VRMMaterialExporter.CreateFromMaterial(srcMaterial, textureManager);
+ var vrmMaterial = VRMMaterialExporter.CreateFromMaterial(srcMaterial, textureExporter);
Assert.AreEqual(vrmMaterial.vectorProperties["_MainTex"], new float[] { 0.3f, 0.2f, 0.5f, 0.6f });
var materialImporter = new VRMMaterialImporter(new glTF_VRM_extensions
diff --git a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs
index f4fb55ac4..3fc350325 100644
--- a/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs
+++ b/Assets/VRM10/Runtime/IO/Material/Vrm10MToonMaterialExporter.cs
@@ -12,7 +12,7 @@ namespace UniVRM10
{
public static class Vrm10MToonMaterialExporter
{
- public static bool TryExportMaterialAsMToon(Material src, TextureExporter textureExporter, out glTFMaterial dst)
+ public static bool TryExportMaterialAsMToon(Material src, ITextureExporter textureExporter, out glTFMaterial dst)
{
try
{
diff --git a/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs b/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs
index 8be4a96a4..5dccd34e5 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10MaterialExporter.cs
@@ -6,7 +6,7 @@ namespace UniVRM10
{
public class Vrm10MaterialExporter : MaterialExporter
{
- public override glTFMaterial ExportMaterial(Material m, TextureExporter textureExporter)
+ public override glTFMaterial ExportMaterial(Material m, ITextureExporter textureExporter)
{
if (Vrm10MToonMaterialExporter.TryExportMaterialAsMToon(m, textureExporter, out var dst))
{
diff --git a/Assets/VRMShaders/GLTF/IO/Runtime/TextureExporter.cs b/Assets/VRMShaders/GLTF/IO/Runtime/TextureExporter.cs
index 06547f4b1..1445896de 100644
--- a/Assets/VRMShaders/GLTF/IO/Runtime/TextureExporter.cs
+++ b/Assets/VRMShaders/GLTF/IO/Runtime/TextureExporter.cs
@@ -11,7 +11,7 @@ namespace VRMShaders
/// glTF にエクスポートする Texture2D を蓄えて index を確定させる。
/// Exporter の最後でまとめて Texture2D から bytes 列を得て出力する。
///
- public class TextureExporter : IDisposable, ITextureExporter
+ public sealed class TextureExporter : IDisposable, ITextureExporter
{
private readonly ITextureSerializer m_textureSerializer;
private readonly Dictionary m_exportMap = new Dictionary();