Search Unity

Sprite Atlas Where is the "registeredSpriteAtlasTags" In Preview 4?

Discussion in '2D Experimental Preview' started by lth3726381, May 28, 2017.

  1. lth3726381

    lth3726381

    Joined:
    Oct 15, 2013
    Posts:
    9
  2. Johaness_Reuben

    Johaness_Reuben

    Unity Technologies

    Joined:
    Jan 27, 2016
    Posts:
    253
    Currently that has been removed. Could you provide more details how you were using it? I read the post you linked, maybe a bit more detail in the process would help us understand the usefulness. :)
     
  3. lth3726381

    lth3726381

    Joined:
    Oct 15, 2013
    Posts:
    9
    I wrote a demo to explain why I need atlas infomation (tag or reference) from a sprite,check out the attached file and run test scene.

    The key code :
    Code (CSharp):
    1. void LocalizedSpriteRenderer(SpriteRenderer sptRenderer, Language language) {
    2.         string atlasName;
    3.         //solution 1 : get atlasName from a custom record :(
    4.         atlasName = sptRenderer.GetComponent<CustomAtlasRecord>().SpriteTag;
    5.         //if we have a property like Sprite.tags,I will not need a CustomRecord :)
    6.         //atlasName=sptRenderer.sprite.tags[0];//most sprite only have one tag
    7.  
    8.         //make atlasName to localized AtlasName
    9.         var localizedAtlasName = language + "/" + atlasName;
    10.         //load atlas from Resources
    11.         var localizedAtlas = Resources.Load<SpriteAtlas>(localizedAtlasName);
    12.  
    13.         //get correspond sprite
    14.         string currentlySpriteName = sptRenderer.sprite.name;
    15.         sptRenderer.sprite = localizedAtlas.GetSprite(currentlySpriteName);
    16.         sptRenderer.sprite.name = currentlySpriteName;//... why a sprite get from atlas called xxx(clone) :(
    17.     }
    BTW: Where is the " Runtime swap atlases and automatically rebind with loaded sprite renderers " feature ,the roadmap show it ,but can't found.
     

    Attached Files:

unityunity