octo-code / webp-unity3d

unity3d version of webp
Apache License 2.0
39 stars 16 forks source link

Allow to keep Texture2D as read-write enabled #17

Open der-hugo opened 1 year ago

der-hugo commented 1 year ago

See https://stackoverflow.com/questions/75050788/how-to-create-webp-image-file-from-url-in-unity/75056837#75056837

In CreateTexture2DFromWebP you are using

lTexture2D.Apply(lMipmaps, true);

which prevents later read/write on that texture.

You could have a parameter

public static unsafe Texture2D CreateTexture2DFromWebP(byte[] lData, bool lMipmaps, bool lLinear, out Error lError, bool isReadWriteEnabled = false, ScalingFunction scalingFunction = null )

and then use

lTexture2D.Apply(lMipmaps, !isReadWriteEnabled);

so users can still keep it enabled if they want/need to.