Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture is not loading properly while passing the format #8

Open
ragavendranbala opened this issue Aug 15, 2023 · 2 comments
Open

Texture is not loading properly while passing the format #8

ragavendranbala opened this issue Aug 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ragavendranbala
Copy link

public Texture2D tex;

var tex1 = TextureOps.Scale(tex, tex.width / 2, tex.height / 2, tex.format);
yield return null;
originalImage.sprite = Sprite.Create(tex1, new Rect(0, 0, tex1.width, tex1.height), new Vector2(0.5f, 0.5f),
100f, 0, SpriteMeshType.FullRect);

I tried to scale down the texture by using the above method and tried to apply to a image. But It always show some lines instead of original one

Image used
forest

converted Image
image

Error :
Unable to retrieve image reference
UnityEngine.Texture2D:ReadPixels (UnityEngine.Rect,int,int,bool)
TextureOps:Scale (UnityEngine.Texture,int,int,UnityEngine.TextureFormat,TextureOps/Options) (at ./Library/PackageCache/com.yasirkula.textureops@66623dae8d/Plugins/TextureOps/TextureOps.cs:467)
ImageConvert/d__6:MoveNext () (at Assets/ImageConvert.cs:35)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Import settings
image

Unity 2022.3.7

Adding aspect ratio fill/scale will also a good option for this asset!

@ragavendranbala ragavendranbala added the bug Something isn't working label Aug 15, 2023
@yasirkula
Copy link
Owner

yasirkula commented Aug 15, 2023

I'd like to know if this is Compression related. Can you set it to None for testing purposes?

PS. Does TextureOps.ScaleFill satisfy the aspect ratio fill/scale you've mentioned?

@ragavendranbala
Copy link
Author

ragavendranbala commented Aug 16, 2023

If I didn't pass the format, it is working good

Haven't tested the fill API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants