-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
CreateFromImageAsync Texture2D does not work async / SupportsTextureFormatNative error #2
Comments
Sorry for the late reply. Looks like Unity is going into a way to make multi-threading even more restrictive. You can try to create an empty texture before hand and use the method variants that update the existing texture. I will look further to see what I can do with this. |
@Looooong Try converting the Texture2D creation to using GraphicsFormat instead of TextureFormat it's in the UnityEngine.Experimental.Rendering namespace. I find that it bypasses the SupportsTextureFormat call, so maybe it could bypass this error? |
Good call, can you test it and submit a PR for this? |
Just tested it out, and the same error happens. So this doesn't work to fix the issue |
Yeah i tried a few other things with the same result. In my game we have a similar library that we put together and we just create the texture2d on the main thread and get GetRawTextureData and give that to a Task to load into without stalling the main thread. The actual calling code isnt async just the internals. |
Now that I take a look at the code again, I find it weird, because Therefore, something like this doesn't work: void Start() {
Task.Run(() => CreateFromImageAsync(data));
} But, this works: async void Start() {
await CreateFromImageAsync(data);
} I tested the wrong way and reproduced the same error message. |
@Looooong I get the following error when calling CreateFromImageAsync from a thread:
Unity 2020.3.1. AFAIK it's impossible to create a new Texture2D on anything but the main thread? Though that seems to render this whole repo useless, which I hope isn't the case cuz it looks GREAT otherwise!
Here's the full stack trace:
and the method I'm calling it from:
The text was updated successfully, but these errors were encountered: