StansAssets / com.stansassets.foundation

Collection of utility methods, design patterns, and extensions for Unity.
https://stansassets.com/
MIT License
129 stars 12 forks source link

feat: added method for texture to texture2D conversion #76

Closed Yurii-Tor closed 3 years ago

Yurii-Tor commented 3 years ago

Purpose of this PR

Often the Texture2D API is needed but texture represents the Texture class (or just Texture2D type is needed).

Testing status

Manual testing status

Tested using Editor

Comments to reviewers

It uses Native Ptr, so please check that in different builds (Android/iOS should work, but not tested). The API Refference for Native Ptr says the following: "On platforms that do not support native code plug-ins, this function always returns NULL." It's hard to say which platforms do so. In case of coming accross that issue, I know a slow but convenient solution with Blitting like here: https://answers.unity.com/questions/1298366/rawimagetexture-to-texture2d.html

Native Ptr API ref: https://docs.unity3d.com/ScriptReference/Texture.GetNativeTexturePtr.html