Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

How do serialized Texture2D fields store and manage Texture2D data pulled from a dll ?

$
0
0
I am asking this question to find out exactly how a serialized texture2D field store and manage data ? **more so** if the texture2D data that populates the texture2D field comes from a dll resource. I ask this because my correctly serialized class and Texture field loses data after assembly reload except for entering and exit of play mode . This was not the case before I moved my textures to a dll. In my dll I have a class which accesses the executing assembly, calls `GetManifestResourceStream` (path to texture image), passes it to a stream. converts that stream to a byte array . then passes the byte array into the `LoadImage()` method of a new Texture2D which when returned gives us out texture . [See Code and detail here ][1] In truth i'm not sure which from to focus on ,should I find out more about how texture data generated and pulled from a dll is handled by the Unity serialization system or should I just focus on my code because a bug may be there or something. But anyway , the code gives me the texture image which I have used many times but for some reason any texture it passes to a Texture field will not persist through an assembly reload . The data only **seemed to persist** because I pulled handled my code like this : We mark up out class to serialize correctly [System.Serializable] `public class SomeClass{.......` [SerializeField] private Texture2D myTexture ; `void OnEnable() { myTexture = (function to get resource image from dll) this made me believe that myTexture was persistin through assembly reloads }` instead of `void OnEnable() { if(myTexture == null) myTexture = (function to get resource image from dll) this made me realise that myTexture was in fact not persisting through reloads }` Same problem with a list of texture2Ds @Bunny83 you seem to have seen the code before [here ][1] I'm not sure what is going on . I thought that Once the data is passed into the serialized Texture2D field that unitys setialization system would hold on on the c++ side and pass it back the the appropriate field after an assembly reload but it kind of seems like the data doesn't even make it to the c++ side even though the field itself is serialized . If i were to use Resources.Load to assign a Txsture2D then i would have no problem so I know that the serialization system is doing its work in that regard. I am in deep confusion . Any help would be appreciated . Also , is there a more efficient way to pull and pass image data from a dll to a Texture2D field now ? since this method is 5 years old. [1]: http://forum.unity3d.com/threads/resources-load-in-c-dll.62561/

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>