Title: CreateFromImageAsync Texture2D does not work async / SupportsTextureFormatNative error · Issue #2 · Looooong/UnityAsyncImageLoader · GitHub
Open Graph Title: CreateFromImageAsync Texture2D does not work async / SupportsTextureFormatNative error · Issue #2 · Looooong/UnityAsyncImageLoader
X Title: CreateFromImageAsync Texture2D does not work async / SupportsTextureFormatNative error · Issue #2 · Looooong/UnityAsyncImageLoader
Description: @Looooong I get the following error when calling CreateFromImageAsync from a thread: UnityException: SupportsTextureFormatNative can only be called from the main thread. Constructors and field initializers will be executed from the loadi...
Open Graph Description: @Looooong I get the following error when calling CreateFromImageAsync from a thread: UnityException: SupportsTextureFormatNative can only be called from the main thread. Constructors and field init...
X Description: @Looooong I get the following error when calling CreateFromImageAsync from a thread: UnityException: SupportsTextureFormatNative can only be called from the main thread. Constructors and field init...
Opengraph URL: https://github.com/Looooong/UnityAsyncImageLoader/issues/2
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CreateFromImageAsync Texture2D does not work async / SupportsTextureFormatNative error","articleBody":"@Looooong I get the following error when calling CreateFromImageAsync from a thread:\r\n\r\n\u003e UnityException: SupportsTextureFormatNative can only be called from the main thread.\r\n\u003e Constructors and field initializers will be executed from the loading thread when loading a scene.\r\n\r\nUnity 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!\r\n\r\nHere's the full stack trace:\r\n```\r\nUnityException: SupportsTextureFormatNative can only be called from the main thread.\r\nConstructors and field initializers will be executed from the loading thread when loading a scene.\r\nDon't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.\r\nUnityEngine.EditorSystemInfo.SupportsTextureFormat (UnityEngine.TextureFormat format) (at \u003c10564ed154d647e194bef4aef8878649\u003e:0)\r\nUnityEngine.SystemInfoShimBase.SupportsTextureFormat (UnityEngine.TextureFormat format) (at \u003c10564ed154d647e194bef4aef8878649\u003e:0)\r\nUnityEngine.SystemInfo.SupportsTextureFormat (UnityEngine.TextureFormat format) (at \u003c10564ed154d647e194bef4aef8878649\u003e:0)\r\nUnityEngine.Texture.ValidateFormat (UnityEngine.TextureFormat format) (at \u003c10564ed154d647e194bef4aef8878649\u003e:0)\r\nUnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.TextureFormat textureFormat, System.Int32 mipCount, System.Boolean linear, System.IntPtr nativeTex) (at \u003c10564ed154d647e194bef4aef8878649\u003e:0)\r\nUnityEngine.Texture2D..ctor (System.Int32 width, System.Int32 height, UnityEngine.TextureFormat textureFormat, System.Int32 mipCount, System.Boolean linear) (at \u003c10564ed154d647e194bef4aef8878649\u003e:0)\r\nAsyncImageLoader+ImageImporter+\u003cCreateNewTextureAsync\u003ed__17.MoveNext () (at Assets/UnityAsyncImageLoader/Runtime/ImageImporter.cs:100)\r\n--- End of stack trace from previous location where exception was thrown ---\r\nSystem.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at \u003ceae584ce26bc40229c1b1aa476bfa589\u003e:0)\r\nSystem.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at \u003ceae584ce26bc40229c1b1aa476bfa589\u003e:0)\r\nSystem.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at \u003ceae584ce26bc40229c1b1aa476bfa589\u003e:0)\r\nSystem.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at \u003ceae584ce26bc40229c1b1aa476bfa589\u003e:0)\r\nSystem.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () (at \u003ceae584ce26bc40229c1b1aa476bfa589\u003e:0)\r\nAsyncImageLoader+\u003cCreateFromImageAsync\u003ed__9.MoveNext () (at Assets/UnityAsyncImageLoader/Runtime/AsyncImageLoader.cs:105)\r\nUnityEngine.Debug:LogException(Exception)\r\n\u003cCreateFromImageAsync\u003ed__9:MoveNext() (at Assets/UnityAsyncImageLoader/Runtime/AsyncImageLoader.cs:108)\r\nSystem.Threading._ThreadPoolWaitCallback:PerformWaitCallback()\r\n```\r\nand the method I'm calling it from:\r\n```\r\nprivate static async Task\u003cTexture2D\u003e ByteArrayToTexture2D(byte[] bytes)\r\n{\r\n return await AsyncImageLoader.CreateFromImageAsync(bytes);\r\n}\r\n```","author":{"url":"https://github.com/nickyonge","@type":"Person","name":"nickyonge"},"datePublished":"2021-10-11T22:40:43.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/2/UnityAsyncImageLoader/issues/2"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d1e634c0-ee95-5732-9ab4-db7cda3255d1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A69C:190AD7:60D9ED:809142:6A5B44AB |
| html-safe-nonce | a998f7f58b6de616d457a01d6f595afc7060be87b88f6b5549d16ad02d8f7f7f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNjlDOjE5MEFENzo2MEQ5RUQ6ODA5MTQyOjZBNUI0NEFCIiwidmlzaXRvcl9pZCI6IjI1MTM4OTYyNTkzOTczOTgxOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4f2ca8a5589441d0853727c13948651378f9540d229a3dcdef96d1754a965e75 |
| hovercard-subject-tag | issue:1023178342 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/Looooong/UnityAsyncImageLoader/2/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d65c7ffef4f8f0e3db715bb890255b2e3c05f50c1f64d08ebccae1ef8640176b/Looooong/UnityAsyncImageLoader/issues/2 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d65c7ffef4f8f0e3db715bb890255b2e3c05f50c1f64d08ebccae1ef8640176b/Looooong/UnityAsyncImageLoader/issues/2 |
| og:image:alt | @Looooong I get the following error when calling CreateFromImageAsync from a thread: UnityException: SupportsTextureFormatNative can only be called from the main thread. Constructors and field init... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nickyonge |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/Looooong/UnityAsyncImageLoader git https://github.com/Looooong/UnityAsyncImageLoader.git |
| octolytics-dimension-user_id | 8206622 |
| octolytics-dimension-user_login | Looooong |
| octolytics-dimension-repository_id | 389617796 |
| octolytics-dimension-repository_nwo | Looooong/UnityAsyncImageLoader |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 389617796 |
| octolytics-dimension-repository_network_root_nwo | Looooong/UnityAsyncImageLoader |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width