Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Atlases and sprites

Discussion in '2D' started by JohnGallet, Nov 21, 2013.

  1. JohnGallet

    JohnGallet

    Joined:
    Sep 27, 2013
    Posts:
    16
    It is a stupid question, but I can't get any help from the doc of the v4.3.

    I have an atlas with 128x8 sprites.
    I can slice them with the new sprite import features.

    Now I just want to display them (1,2,3,4,5 and loop).

    I just can't find how to tell the sprite renderer which index in the atlas it has to display.

    Anyone got this problem and solved it? (I use JS)

    Note
    spriteRenderer.sprite=spritelist[currentsprite];
    is not working while

    lineRenderer would support this syntax.
     
    Last edited: Nov 21, 2013
  2. JohnGallet

    JohnGallet

    Joined:
    Sep 27, 2013
    Posts:
    16
    Ok I found the solution:

    gameObject.GetComponent(SpriteRenderer).sprite=spritelist[currentsprite];
     
  3. amjadyahya

    amjadyahya

    Joined:
    Nov 16, 2013
    Posts:
    11
    I've been trying to do this for a long time with no luck, could you elaborate more on this .. maybe post the exact code of how you created the object and assigned a particular slice to it.

    Thanks in advance