Search Unity

Question about Sprite references and memory management in Unity

Discussion in '2D' started by fokziu, Jan 13, 2016.

  1. fokziu

    fokziu

    Joined:
    Apr 10, 2015
    Posts:
    7
    I have a question about inner-workings of unity - If I have a public reference in MonoBehaviour to a Sprite (thats assignable from UnityEditor as property), does it load the sprite metadata only or maybe also its texture? I guess its probably the lazy-programmer solution and it does load everything but It could load metadata only and as soon as there are active references to the sprite from SpriteRenderers the actual texture could get loaded. Does anyone know how its actually implemented?

    The problem is that one of our programmers was given a task to add some localization support to our game.

    We cannot use resources and do the obvious thing like: Resources.Load<Sprite>("our_fancy_sprite" + currentLangExt) at runtime to get the properly localized sprite because there are two major drawbacks with resources. It explodes while building when it has lots of sprites (32bit unity problem). Also SpritePacker does not want to pack sprites that live in resources which is a huge drawback especially when mobile 2d games are involved and there might be a couple of sprites that should get localized and would be happy to live together on one atlas.

    So the only option was to create a scritpt that has references to localized sprites which kinda sucks. I am worried about memory and also its hardly elegant as it requires to change stuff in editor as well as code the moment we decide to add another languague.

    What are your approaches to do localization excluding AssetBundles and Variants which are at least now totally broken and unusable in my opinion?