Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

What do I do after using texture packer

Discussion in 'Scripting' started by keithsoulasa, Oct 26, 2012.

  1. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    I packed some sprites together with texture packer , how do I now use them in unity .
    I DO NOT want to use othellio .

    What would I code to read this ?

    Code (csharp):
    1.  
    2. {"frames": {
    3.  
    4. "1.png":
    5. {
    6.     "frame": {"x":64,"y":166,"w":60,"h":80},
    7.     "rotated": false,
    8.     "trimmed": true,
    9.     "spriteSourceSize": {"x":3,"y":3,"w":60,"h":80},
    10.     "sourceSize": {"w":78,"h":86}
    11. },
    12. "2.png":
    13. {
    14.     "frame": {"x":64,"y":84,"w":60,"h":80},
    15.     "rotated": false,
    16.     "trimmed": true,
    17.     "spriteSourceSize": {"x":3,"y":3,"w":60,"h":80},
    18.     "sourceSize": {"w":78,"h":86}
    19. },
    20. "3.png":
    21. {
    22.     "frame": {"x":64,"y":2,"w":60,"h":80},
    23.     "rotated": false,
    24.     "trimmed": true,
    25.     "spriteSourceSize": {"x":4,"y":3,"w":60,"h":80},
    26.     "sourceSize": {"w":78,"h":86}
    27. },
    28. "4.png":
    29. {
    30.     "frame": {"x":2,"y":176,"w":60,"h":78},
    31.     "rotated": false,
    32.     "trimmed": true,
    33.     "spriteSourceSize": {"x":3,"y":5,"w":60,"h":78},
    34.     "sourceSize": {"w":78,"h":86}
    35. },
    36. "5.png":
    37. {
    38.     "frame": {"x":2,"y":90,"w":60,"h":84},
    39.     "rotated": false,
    40.     "trimmed": true,
    41.     "spriteSourceSize": {"x":3,"y":0,"w":60,"h":84},
    42.     "sourceSize": {"w":78,"h":86}
    43. },
    44. "6.png":
    45. {
    46.     "frame": {"x":2,"y":2,"w":60,"h":86},
    47.     "rotated": false,
    48.     "trimmed": true,
    49.     "spriteSourceSize": {"x":3,"y":0,"w":60,"h":86},
    50.     "sourceSize": {"w":78,"h":86}
    51. }},
    52. "meta": {
    53.     "app": "http://www.texturepacker.com",
    54.     "version": "1.0",
    55.     "image": "yes.png",
    56.     "format": "RGBA8888",
    57.     "size": {"w":128,"h":256},
    58.     "scale": "1",
    59.     "smartupdate": "$TexturePacker:SmartUpdate:94bd07f712b8503d5204da64cacad41e$"
    60. }
    61. }
    62.  
    63.  
     
  2. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Change texture offsets?
     
  3. Bladesfist

    Bladesfist

    Joined:
    Jan 3, 2012
    Posts:
    107
  4. keithsoulasa

    keithsoulasa

    Joined:
    Feb 15, 2012
    Posts:
    2,126
    Ok , I'm halfway their
    Code (csharp):
    1.  
    2. void Start(){      
    3. var animatedSprite = UI.firstToolkit.addSprite( "1.png", 0, 0, 1 );
    4.         var anim = animatedSprite.addSpriteAnimation( "anim", 0.15f, "1.png", "2.png", "3.png", "4.png", "5.png" );
    5.         animatedSprite.positionFromBottomRight( .0f, .25f );
    6.         anim.loopReverse = true; // optinally loop in reverse
    7.         animatedSprite.playSpriteAnimation( "anim", 3 );
    8. }
    The only problem is I can't change the sprites position latter since these are just local varibles . How would I make them global for the entire script .