I guess it's because Stream on the Android platform doesn't support certain methods, and I've encountered similar issues using the SharpGLTF library before.
my code:
publicstaticTextureImportTextureHdrFromStream(StreamReaderstreamReader,TextureImportSettingsetting){if(setting.FlipVertically){StbImage.stbi_set_flip_vertically_on_load(1);}varimageResult=ImageResultFloat.FromStream(streamReader.BaseStream);if(setting.FlipVertically){StbImage.stbi_set_flip_vertically_on_load(0);}if(imageResult!=null){vartexture=newTexture{Width=(uint)imageResult.Width,Height=(uint)imageResult.Height,Channel=imageResult.Comp.ToTexChannel()};texture.IsGammaSpace=setting.IsGammaSpace;texture.HDRPixels=new(imageResult.Data);texture.IsHdrTexture=true;returntexture;}thrownewException("Load Texture error");}The stream is from
newStreamReader(Activity.Assets.Open($"Resource/{Path}"));When I make the following modifications, it can avoid this problem
publicstaticTextureImportTextureHdrFromStream(StreamReaderstreamReader,TextureImportSettingsetting){MemoryStreamms=newMemoryStream();using(BinaryReaderbr=newBinaryReader(streamReader.BaseStream)){List<byte>buffer=newList<byte>();do{vardata=br.ReadBytes(1024);if(data.Length<=0)break;ms.Write(data);}while(true);}if(setting.FlipVertically){StbImage.stbi_set_flip_vertically_on_load(1);}varimageResult=ImageResultFloat.FromStream(ms);if(setting.FlipVertically){StbImage.stbi_set_flip_vertically_on_load(0);}if(imageResult!=null){vartexture=newTexture{Width=(uint)imageResult.Width,Height=(uint)imageResult.Height,Channel=imageResult.Comp.ToTexChannel()};texture.IsGammaSpace=setting.IsGammaSpace;texture.HDRPixels=new(imageResult.Data);texture.IsHdrTexture=true;returntexture;}thrownewException("Load Texture error");}
I guess it's because Stream on the Android platform doesn't support certain methods, and I've encountered similar issues using the SharpGLTF library before.
my code:
The stream is from
When I make the following modifications, it can avoid this problem