Change *Import Settings* for Downloaded Textures

Hello everyone, thank you so much in advance for your help.

Context:
I have a texture that I download from a php file using UnityWebRequest
and Texture2D.LoadImage(byte[ ] bytes).

Problem:
I am able to use this texture in the UI of my game, but I would like to modify the import settings like how I usually do from the inspector in my project. (I mainly want to set Compression → None)

I know about the AssetPostprocessor but I don’t know how to apply it to a texture which I don’t have a path to in my project folder.

Here is my code:

// results as byte array
                byte[] bytes = www.downloadHandler.data;

                //Create texture2D
                Texture2D texture = new Texture2D(2, 2);
                texture.LoadImage(bytes);

                //Change Import Settings
                UnityEditor.AssetPostprocessor assetPostprocessor = new UnityEditor.AssetPostprocessor();
                UnityEditor.TextureImporter importer = assetPostprocessor.assetImporter as
UnityEditor.TextureImporter;
                importer.textureCompression = UnityEditor.TextureImporterCompression.Uncompressed;
                //...To do: Apply importer settings to texture
                //Can I even do this from monobehaviour?

                //Create sprite (to be placed in UI)
                Sprite sprite = Sprite.Create(texture, new Rect(0,0, texture.width, texture.height), new
Vector2(0.5f,0.5f));
                callback(sprite);

If anyone has any leads or suggestions I would be truly grateful.
Best regards

Is this for runtime? All the editor stuff is not available if it is. In that case, any compression you see will have come form the original image: once an image is in memory, it’s just what it is, there is no further import step.

If you’re just doing this in the editor, just write the file to disk somewhere in your project and then select it in the editor and set the settings, or do it with an Editor script.