mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-25 07:28:51 -05:00
fix vrmAssetPostprocessor
TextureのAssetImportが3種類になったのに対応 * ScriptedImporter(subAsset) * ScriptedImporter(ExternalObject) * AssetPostProcessor(from TextureAsset)
This commit is contained in:
parent
cc06f55961
commit
14c39b61be
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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>();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user