public IEnumerator CovertToSkyboxCoroutine(glTFCubemapTexture cubemapTexture, SkyboxImporterResult result) { var cubemapResult = new CubemapTextureImporterResult(); yield return(_importer.ConvertCubemapCoroutine(cubemapTexture, cubemapResult)); var mat = new Material(_skyboxPrefab); mat.SetTexture(TexProperty, cubemapResult.Result); result.Result = mat; }
public IEnumerator ConvertCubemapCoroutine(glTFCubemapTexture gltfCubemapTexture, CubemapTextureImporterResult result) { var success = true; var mipLength = gltfCubemapTexture.mipmapCount; // original を含めない mipmap だけの個数 var width = _textureGetter(gltfCubemapTexture.texture.cubemapPositiveX.index).Texture.width; var cubemap = new Cubemap(width, TextureFormat.RGBAHalf, mipLength + 1); // Set original var successResult = new CoroutineSuccessResult(); yield return(UpdateCubemapFace(gltfCubemapTexture.texture, cubemap, 0, successResult)); success &= successResult.Result; // Set mipmaps for (var idx = 0; idx < mipLength; ++idx) { var tex = gltfCubemapTexture.mipmapTextures[idx]; var mipValue = idx + 1; var mipmapSuccessResult = new CoroutineSuccessResult(); yield return(UpdateCubemapFace(tex, cubemap, mipValue, mipmapSuccessResult)); success &= mipmapSuccessResult.Result; } // Apply cubemap.Apply(updateMipmaps: false, makeNoLongerReadable: true); yield return(null); if (success) { result.Result = cubemap; } else { UnityEngine.Object.DestroyImmediate(cubemap); } }