fix vrmAssetPostprocessor

TextureのAssetImportが3種類になったのに対応

* ScriptedImporter(subAsset)
* ScriptedImporter(ExternalObject)
* AssetPostProcessor(from TextureAsset)
This commit is contained in:
ousttrue 2021-03-01 20:29:41 +09:00
parent cc06f55961
commit 14c39b61be
4 changed files with 25 additions and 7 deletions

View File

@ -138,7 +138,11 @@ namespace UniGLTF
};
foreach (var o in ObjectsForSubAsset())
{
if (o == null) continue;
if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(o)))
{
// already exists
continue;
}
var assetPath = GetAssetPath(prefabPath, o, meshAsSubAsset);
if (!assetPath.IsNull)

View File

@ -19,10 +19,12 @@ namespace UniGLTF
{
Debug.LogWarningFormat("fail to get TextureImporter: {0}", m_assetPath);
}
importer.maxTextureSize = 8192;
importer.sRGBTexture = !isLinear;
importer.SaveAndReimport();
else
{
importer.maxTextureSize = 8192;
importer.sRGBTexture = !isLinear;
importer.SaveAndReimport();
}
var Texture = m_assetPath.LoadAsset<Texture2D>();

View File

@ -51,7 +51,19 @@ namespace VRM
var prefabPath = path.Parent.Child(path.FileNameWithoutExtension + ".prefab");
// save texture assets !
var context = new VRMImporterContext(parser);
LoadTextureAsyncFunc textureLoader = async (textureIndex, used) =>
{
var textureType = TextureIO.GetglTFTextureType(parser.GLTF, textureIndex);
var colorSpace = TextureIO.GetColorSpace(textureType);
var isLinear = colorSpace == RenderTextureReadWrite.Linear;
var sampler = parser.GLTF.GetSamplerFromTextureIndex(textureIndex);
var gltfTexture = parser.GLTF.textures[textureIndex];
var gltfImage = parser.GLTF.images[gltfTexture.source];
var assetPath = prefabPath.Parent.Child(gltfImage.uri);
var texture = await UniGLTF.AssetTextureLoader.LoadTaskAsync(assetPath, isLinear, sampler);
return new TextureLoadInfo(texture, used, false);
};
var context = new VRMImporterContext(parser, textureLoader);
var editor = new VRMEditorImporterContext(context);
editor.ExtractImages(prefabPath);

View File

@ -14,7 +14,7 @@ namespace VRM
{
public VRM.glTF_VRM_extensions VRM { get; private set; }
public VRMImporterContext(GltfParser parser) : base(parser)
public VRMImporterContext(GltfParser parser, UniGLTF.LoadTextureAsyncFunc asyncTextureLoader = null) : base(parser, asyncTextureLoader)
{
// parse VRM part
if (glTF_VRM_extensions.TryDeserilize(GLTF.extensions, out glTF_VRM_extensions vrm))