Hello, in our mobile game, we have some images to download, and all of them need to be downloaded from the server using POST method.
The UnityWebRequest class has the option to use it, but UnityWebRequestTexture only has GET option.
So we are forced to use legacy WWW class for this…
Is there ever going to be a way to use POST with UnityWebRequestTexture?
Thank you!
You are not forced to anything. UnityWebRequestTexture only has common convenient methods. All they do is configure UnityWebRequest.
A simplest way to achieve what you want is to do UnityWebRequest.Post and then assign DownloadHandlerTexture to downloadHandler property. It has a small cost of creating and discarding DownloadHandlerBuffer. It you want to avoid that, configure everything yourself.
Thanks for the answer, but what does exactly mean “configure everything yourself”? You mean an alternative approach still using UnityWebRequestTexture? Or you mean developing from scratch a way to download images?
In means creating UnityWebRequest with new operator and either using the correct constructor with desired values or setting relevant properties after creation. All these UnityWebRequest.Get and similar are just convenience methods on top of that, they create new UWR and set the url, method, download and upload handlers to certain values.
See:
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest-ctor.html
Got it, I understand how it works now, thank you!