StandardMap の AssetKey の比較を修正

This commit is contained in:
ousttrue
2021-04-20 14:03:06 +09:00
parent 1cd4c3d951
commit 01241ac7be
2 changed files with 10 additions and 4 deletions

View File

@@ -63,10 +63,14 @@ namespace UniGLTF
case TextureImportTypes.StandardMap:
{
// write converted texture
var (_, subAsset) = m_subAssets.FirstOrDefault(x => x.Equals(key));
var (_, subAsset) = m_subAssets.FirstOrDefault(kv => kv.Key.Equals(key));
if (subAsset == null)
{
throw new KeyNotFoundException();
}
targetPath = m_textureDirectory.Child($"{key.Name}.png");
File.WriteAllBytes(targetPath.FullPath, subAsset.EncodeToPNG().ToArray());
// targetPath.ImportAsset();
targetPath.ImportAsset();
break;
}
@@ -75,7 +79,7 @@ namespace UniGLTF
// write original bytes
targetPath = m_textureDirectory.Child($"{key.Name}{param.Ext}");
File.WriteAllBytes(targetPath.FullPath, param.Index0().Result.ToArray());
// targetPath.ImportAsset();
targetPath.ImportAsset();
break;
}
}

View File

@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
@@ -92,7 +93,8 @@ namespace UniGLTF
// extractor
var extractor = new TextureExtractor(parser, UnityPath.FromUnityPath(""), loader.TextureFactory.Textures.Select(x => (new SubAssetKey(typeof(Texture2D), x.Texture.name), x.Texture)).ToArray());
var m = GltfTextureEnumerator.EnumerateTexturesForMaterial(parser, 0).FirstOrDefault(x => x.Item1.Name == "texture_1.standard");
extractor.Extract(m.Item1, m.Item2);
Assert.Catch<NotImplementedException>(() => extractor.Extract(m.Item1, m.Item2));
}
}
}