Serialize Sprites
Pretty much the title. I tried with RPC's but it didn't work. Any help would be great thanks!
0
Comments
-
@bananashavings
IMO, you should get theSprite
'sTexture2D
and convert it to abyte[]
then exchange it.0 -
Hi bananashavings.
You should rethink, WHY you want to do this and if there isn't a better alternative to serializing sprites.
Serializing sprites is nearly never a good idea as it usually just wastes lots of traffic for no benefit whatsoever. Practically always the better approach is to store all sprites (and the same goes for any other assets like textures, 3dmodels, soundfiles, and so on) locally on the clients and to just send around the ids of the sprites instead of the sprites themselves, so that the local clients know what sprites to display.1 -
I just want to add something to @Kaiserludi's good answer:
There may be use cases where you want to store Sprites or other game assets on server side and download them on runtime and on demand to the client. You need to grant client access to the URLs of those assets and download them using Unity's WWW class.0 -
Is there a snippet you could share with me?JohnTube said:@bananashavings
IMO, you should get theSprite
'sTexture2D
and convert it to abyte[]
then exchange it.0 -
@bananashavings
I hope that you did rethink twice and considered what @Kaiserludi mentioned in his answer.
I want to add that you can also make use of Base64 strings.
You can access full source code of a set of extension methods of [from/to] Sprite serialiaztion here.0