Skip to content

Commit

Permalink
Log error when trying to export missing texture (e.g when trying to e…
Browse files Browse the repository at this point in the history
…xport a cubemap in gltf)
  • Loading branch information
marwie committed Sep 8, 2022
1 parent 59eb59f commit 2085ebc
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ private void ExportImages(string outputPath)
/// <param name="outputPath">The location to export the texture</param>
private void ExportMetallicGlossTexture(Texture2D texture, string outputPath, bool swapMetalGlossChannels)
{
if (!texture)
{
UnityEngine.Debug.LogError("Can not export missing texture: " + outputPath);
return;
}
var destRenderTexture = RenderTexture.GetTemporary(texture.width, texture.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
if (swapMetalGlossChannels)
Graphics.Blit(texture, destRenderTexture, _metalGlossChannelSwapMaterial);
Expand Down Expand Up @@ -296,9 +301,11 @@ private ImageId ExportImage(Texture texture, TextureMapType textureMapType)
Uri.EscapeDataString(Path.GetFileName(filenamePath))
).Replace("\\","/");

// TODO: handle cubemap export
var imageInfoTexture = texture as Texture2D;
_imageInfos.Add(new ImageInfo
{
texture = texture as Texture2D,
texture = imageInfoTexture,
textureMapType = textureMapType,
outputPath = filenamePath,
canBeExportedFromDisk = canBeExportedFromDisk,
Expand Down

0 comments on commit 2085ebc

Please sign in to comment.