Search Unity

Texture Packer + Unity Tutorial

Discussion in 'Community Learning & Teaching' started by stanislav-osipov, Jun 2, 2013.

  1. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    133
    Unfortunately that's not the case for me; here's what is imported from that package: https://dl.dropboxusercontent.com/u/23284/tp.png

    Ben
     
  2. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    TP helper is not part of the dll.
    See image bellow:

    $Untitled_-_New_Unity_Project_1_-_PC__Mac___Linux_Standalone.png


    Just attach TPMesh Texture Ex to any object and TPHelper will be added automatically.
     
  3. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    133
    Ah I see. I'm afraid I'm not seeing the Docs, Resources or TPCore folders included in the dropbox package. Here's what's imported for me:
    https://dl.dropboxusercontent.com/u/23284/tp2.png

    Is it possible that some files are missing from that package?

    Ben
     
  4. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    133
    Please disregard my last message - I was attempting to overwrite the old version of the lib and hadn't realised that the location had changed. The files were present but were being updated in a separate location. Deleting everything and re-importing worked as expected. My apologies!

    I'm just testing the iOS export now...

    Update: Yep, it all works as expected. Thank you very much for your help lacost! :)

    Ben
     
    Last edited: Oct 14, 2013
  5. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    I glad that you solve your problem. Good luck with your project :)

    Cheers!
     
    Last edited: Oct 14, 2013
  6. Jerome-Maurey

    Jerome-Maurey

    Joined:
    May 6, 2013
    Posts:
    6
  7. Webjema

    Webjema

    Joined:
    Aug 8, 2012
    Posts:
    13
    Hi. Thank you for good tool.
    I use Pro version and have problem with sliced-9 sprites.
    I use NGUI for my game.
    The problem is in sliced-9 sprites. When I rebuild my atlases I loose info about borders for sliced-9 sprites.
    How I can use TexturePacker + NGUI with sliced-9 sprites? How to save info about borders for these sprites?
    Thank you.

    p.s. Земляк! Круто =))))
     
  8. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hi there. I'm not really understood what are you mean. Just contact me via mail lacost.st@gmail.com and we will solve your problem

    Cheers!

    P.S. Мыло можно писать на русском =) или сразу в скайп lacost_20 =)
     
  9. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Jerome Maurey Update with download example is already submitted. And will be announced as soon as Asset Store team will check it.

    If you need this download example now, just send me e-mail lacost.st@gmail.com and will send you new package.
    Cheers!
     
  10. DMONGS

    DMONGS

    Joined:
    May 25, 2013
    Posts:
    15
    Hi.
    I got a problem.
    TP plug-in worked well until yesterday, but today it doesn't show exact coordinates.
    For example there was a tree in a plane, but now there is solid color in there.
    The data file, atlas image and material are not changed.
    It occurred after I add a TPMeshTexture twice.
    - I'm not sure that it's the real cause because I touched many things today.
    And here is an error I got when I click the "Update" button. ( No error when I call a "UpdateView()" of TPMeshTexture class. )

    ArgumentException: An element with the same key already exists in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,System.String].Add (System.String key, System.String value) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404)
    TPAtlasesData.AddAtlasInfo (System.String atlas, System.String path) (at Assets/Extensions/TexturePacker/TPCore/Helpers/TPAtlasesData.cs:20)
    TPAssetPostprocessor.fillAtlasesDictionary () (at Assets/Extensions/TexturePacker/TPCore/Editor/Data/TPAssetPostprocessor.cs:169)
    TPAssetPostprocessor.UpdateAtlasesInfromation () (at Assets/Extensions/TexturePacker/TPCore/Editor/Data/TPAssetPostprocessor.cs:50)
    TPAssetPostprocessor.get_atlasesNames () (at Assets/Extensions/TexturePacker/TPCore/Editor/Data/TPAssetPostprocessor.cs:75)
    TPHelperEditor.Awake () (at Assets/Extensions/TexturePacker/TPCore/Editor/Components/TPHelperEditor.cs:28)

    Well... is it cache problem? If so, how can I clear it?
    (I'm using pro version.)
     
  11. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello DMONGS. Thanks for purchasing.
    I just did the same thing (add TPMeshTexture twice) there were few errors but they gone as soon as I removed excess component.

    Just delete mesh with problem for your scene and add it again. It should work fine. Because original mesh wasn't affected by extension. If that will not solve your problem, the please send me packages contained your scene with described issue, so I can take closer look on it. Thanks.

    P.S. Guys if you need urgent help. Do not post in this thread contact me directly via e-mail. I will respond much quicker. Basically this thread is for question, suggestion, ect. If you have some problems it can mean two things:
    1) You did something worn. In this case I just will help you to do it in right way.
    2) You found bug in extension. In this case I will fix it ASAP, and will post warning about it to this thread, in case somebody will have same issue.

    Thanks a lot for understanding. Cheers!
     
  12. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    • Runtime Atlases Download Example.
    • Source Code is Open Now!! (Pro version only)
    • Minor bug fixes
     
  13. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Just imported TP Pro.

    Imported everything except Tutorial folder because I don't need it.

    Moved the whole Extensions folder to a different location in my Assets directory tree.

    Now when I open Window / Texture Package, I get an empty tool window that doesn't react to any input, and lots of Exception messages in Console:

    https://dl.dropboxusercontent.com/u/136375/img/screens/unity-tpbroken.png

    So, what now?

    [Unity Pro 4.2.2f1 with -force-opengl, Android Pro build target, Win7 64-bit]
     
  14. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Another problem is, I can't even close that broken/nonresponding TP window now...
     
  15. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    The problem is solved. Thanks for report.

    This issue appears if no atlases detected in project.
    Fixed version will be available shortly in asset store, in the mean time, please do not open Texture Packer Unity Window if you do not have any atlases in the project.
     
  16. concave

    concave

    Joined:
    Aug 28, 2012
    Posts:
    49
    hi lacost! i read the post refering to atlas creation on runtime.

    is it possible to solve the following problem with texture packer pro:?

    my game is a little 3d editor where you can duplicate/translate cubes and attach an image (texture) on one or multiple cubes. you can download another image and add it to mutliple other cubes. so in worst case every cubes has its own texture (256x256) so every cube needs a drawcall. all happens at runtime. you are able to save your cubes and your are able to reload and reedit them - so the atlas creation must happen on every edit step. is it possible to use texturepacker to save drawcalls and solve perfromance issues on an increasing amount of items?

    kind regards
     
  17. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    That is impossible to create atlas in runtime. Because standalone Texture Packer version is responsible for atlas creation.
    However you can download ready made atlases in runtime an use it.
    Cheers!
     
  18. sketchycode

    sketchycode

    Joined:
    Jul 24, 2013
    Posts:
    1
    I didn't see an answer to this so apologies if you already covered it: can the extension create the new unity 2d Sprite objects?
     
  19. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Thanks for your interest. I am working on it.
    This should be covered in future updates.
     
  20. LiveWire

    LiveWire

    Joined:
    Dec 6, 2011
    Posts:
    17
    Hi, I've been trying out the free version and have run into a couple of issues.

    The first is texture bleeding seen below, when mapping meshes to the 0,1 UV borders. I have reduced this problem a great deal by using the Extrude and Padding settings in the TexturePackerGUI under Layout. It now looks much better than the screenshot, however there are still seams when viewed up close and the black padding space becomes visible again as mip levels increase. It also means my textures don't pack in neatly due to everything gaining 2 pixels on either side (so four 256 textures no longer neatly fill a 1024 side). Are these settings the only options for dealing with this problem? Is there a way to clamp the UVs?

    $TPAtlas_01.jpg


    Second, is it possible to assign multiple textures (from the same Atlas) or materials (multiple different Atlases) to the same object? The road texture and grass texture in the images are both in the same Atlas, but it appears that I need to separate them into unique meshes to assign a different texture to them. This also means that the vertex normals at the seam are no longer aligned and need to be manually adjusted to maintain soothing. All of this creates a lot a of extra work in the mesh pipeline. Is there a way to assign multiple textures/materials, or any plans to implement such a feature?

    $TPAtlas_02.jpg

    Texture Packer seems like a very useful tool, but with these problems (in particular the second problem - I can live with the current solution to the first) are stopping me from buying the paid version.
     
  21. metaleap

    metaleap

    Joined:
    Oct 3, 2012
    Posts:
    589
    Sampling atlased textures in a tiled/repeating way will always show seams unless BOTH the following conditions are met:

    1. you have an extrusion padding on each side of eachs sprite that is approx. as many pixels wide/high as will safely mip down to the lower levels. Hard to quantify really.. just be aware that bilinear/trilinear texture filtering in current GPUs always accesses neighboring texels, which is great in a normal repeating texture but immediately leads to such artifacts with atlases. Depends on the use-case then how thick the border would have to be (ie. what's the lowest mip level where such artifacts would be bothersome).

    2. you have a shader that specifically supports tiled/repeating atlased-sprites via texLod or ddx/ddy. If you understand how the shading pipeline and GPU texture filtering work, you'll realize that changing UVs won't be enough to avoid these artifacts. Could do without a shader if you were OK with "Point filtering" only, but nobody wants that unless you're going for that pixelated retro look. Any other filtering will sample neighboring texels as point #1 above. Only a special shader that "knowingly samples into an atlas" will ideally also adjust correct mip-level selection which avoids other nasty (but less obvious to spot at first) rendering artifacts, I don't see how changing UVs on a mesh could possibly do that.

    If you search for "texture atlas seams" or "mip bleeding" (here or on the wider web) you'll learn that this is a timeless problem with no perfect solutions unless you're willing to accept the above two. I've researched for well over a week for a shader of mine "proven and correct" ways to possibly do seam-less atlased-sprite sampling without needing padded borders, I've concluded it's just simply not doable (for me) reliably and generically due to the nature of how GPUs do texture filtering.

    All this is never an issue when using atlases for non-tiled/non-repeating texturing needs -- but you specifically mentioned roads and grass so I felt I had to chip in.
     
    Last edited: Nov 21, 2013
  22. blueivy

    blueivy

    Joined:
    Mar 4, 2013
    Posts:
    633
    Can I store shadow maps in the texture atlas using this?
     
  23. valerik

    valerik

    Joined:
    Aug 8, 2013
    Posts:
    11
    Hi,
    I'm using TexturePacker for 3D Objects and i have some questions:
    1) I noticed that if i move atlas, _data.txt, and material out the example resources folder, it doesn't work anymore. I must put all my atlas in that folder?
    2) It works on iPhone and iPad? using folder path there aren't problems with path?
     
  24. kashif789us

    kashif789us

    Joined:
    May 2, 2013
    Posts:
    163
    Hi, I tried using texture atlas in my game but draw calls increase instead of decreasing :( whats the problem here?
     
  25. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello.

    1) Atlas and _data file should be inside Resources folder. Location of Resources folder and location of atlas inside Resources folder doesn't metter.

    2) Sure, you can use it on any platform.

    Draw calls is depended not only from material sharing. Material sharing only one of condition for dynamic batching to work. Please read more here : DrawCallBatching .
    Any way I always try to help my customers, please e-mail your project or sample (with reproduced issue) as Unity package to lacost.st@gmail.com and I will see what I can do.

    Cheers!
     
  26. aronatvw

    aronatvw

    Joined:
    Mar 15, 2013
    Posts:
    4
    can this be used with a character rig for animation?
     
  27. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Yes, skinned mesh support is there.
    Only make sure your character use 1 material per mesh.
     
  28. BenoitFreslon

    BenoitFreslon

    Joined:
    Jan 16, 2013
    Posts:
    166
    Hello,

    Nice plugins,


    But I can't see my Texture Atlases in the Texture Packer custom window.

    Here my TP settings: http://prntscr.com/2s6ezw

    I see you set import settings in Unity But Should Have set the exact settings of all my sprite atlases?
    http://prntscr.com/2s6fey

    Thanks.
     
  29. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello.
    Thanks, appreciated!

    You should put your atlas and data file inside Resources folder


    No, compression setting is up to you.
    Cheers!
     
  30. OhMyMeGames

    OhMyMeGames

    Joined:
    Mar 12, 2014
    Posts:
    4
    Hi,

    I really dig your plug ins, do u currently have any tutorials or documentation for getting your texture packer + unity plug-in and your After Effects Importer plug-in to work together?

    Thanks
     
  31. bucho

    bucho

    Joined:
    Jan 25, 2014
    Posts:
    5
    Hi,

    how can I create a sprite from a TP atlas with the right aspect (scaling)...?

    I'm using the pro version and watched the videos... but I when I create a "TP Sprite Texture" object as shown in the video I get this error message:

    NullReferenceException: Object reference not set to an instance of an object
    BaseTPConmponents.CopyMesh (UnityEngine.Mesh m) (at Assets/Extensions/TexturePacker/TPSource/Core/3D/BaseTPConmponents.cs:214)


    so only when I use a mesh object (a quad for example) and apply the "TPMesh Texture Ex" component then I get the texture without errors... but the aspect ratio is wrong of course and I would have to rescale the object...

    so is there a way to match the size of the quad mesh object automatically to the texture size...?

    thanks
     
  32. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello, sure. What you are using this is for applying texture to meshes.
    But obviously you need just simile sprite. Here is what you should do:

    Create Texture Packer Sprite:
    https://www.evernote.com/shard/s245...5accbb35f8a186a6aee63b3/deep/0/GameObject.png

    Press the Set button
    https://www.evernote.com/shard/s245...rePackerDev---iPhone,-iPod-Touch-and-iPad.png

    TexturePacker Unity Inspector will be opened
    1) Choose Atlas
    2) Choose Texture
    3) Hit Set Texture

    https://www.evernote.com/shard/s245...rePackerDev---iPhone,-iPod-Touch-and-iPad.png

    That's it, TexturePacker Sprite with right aspect will be created:
    https://www.evernote.com/shard/s245...rePackerDev---iPhone,-iPod-Touch-and-iPad.png
     
  33. bucho

    bucho

    Joined:
    Jan 25, 2014
    Posts:
    5
    Hi,

    thanks for the screenshots...
    I did what you said... but I get an error message :(

    NullReferenceException: Object reference not set to an instance of an object
    BaseTPConmponents.CopyMesh (UnityEngine.Mesh m) (at Assets/Extensions/TexturePacker/TPSource/Core/3D/BaseTPConmponents.cs:214)
    BaseTPConmponents.initUVValues () (at Assets/Extensions/TexturePacker/TPSource/Core/3D/BaseTPConmponents.cs:67)
    BaseTPConmponents.setTile (Single x, Single y) (at Assets/Extensions/TexturePacker/TPSource/Core/3D/BaseTPConmponents.cs:82)
    BaseTPConmponents.showFrame (.TPAtlasTexture texture) (at Assets/Extensions/TexturePacker/TPSource/Core/3D/BaseTPConmponents.cs:190)
    TPMeshTexture.applayUV () (at Assets/Extensions/TexturePacker/TPSource/Core/3D/TPMeshTexture.cs:43)
    TPSprite.showFrame (Int32 index) (at Assets/Extensions/TexturePacker/TPSource/Core/3D/TPSprite.cs:65)
    TPSpriteTexture.OnEditorFrameChange () (at Assets/Extensions/TexturePacker/TPSource/Core/3D/TPSpriteTexture.cs:38 )
    TPSpriteAnimationEditor.Awake () (at Assets/Extensions/TexturePacker/TPCore/Editor/Components/TPSpriteAnimationEditor.cs:34)

    and the "TP Sprite Texture" object does only show the green gizmo (but not in the size or aspect of the texture)... even though the info-text field of the component shoes the right info for "Atlas:" and "Texture:"...

    any idea...?
     
  34. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Looks like you did something wrong, please contact me via e-mail and we will schedule teamviewer session.
    stans.assets@gmail.com
     
  35. bachirk

    bachirk

    Joined:
    Mar 9, 2014
    Posts:
    16
    Thanks for the excellent plugin.

    Is there anyway we can use "Sorting Layers" Unity has.
    Having problems with Zorder of the textures and can't figure out a workaround.
    I can't select nor edit "TP Static Sprite" where the actual renderer is.

    thanks.
     
  36. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Sorting layer that is good feature request thanks. For now you can simply use Z coord, this will work.
     
  37. SealSoul

    SealSoul

    Joined:
    Apr 8, 2014
    Posts:
    3
    How can I change Texture(in the same Atlas) in run time with C# script.
     
  38. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Not sure what you mean by this. Can you explain wider what are you tying to do?
     
  39. SealSoul

    SealSoul

    Joined:
    Apr 8, 2014
    Posts:
    3
    Something like...
    I have picture1 and picture2 in atlas1.
    I add "TPMesh Texture Ex" to plane1 and set "Texture" to picture1.
    How to change plane1's texture to picture2 in runtime?

    thank you.
     
  40. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Well that is simple:
    1) If you need an example simply open RuntimeAtlasTextureSwitch with comes with plugin.

    2)If you need to swish texture you can use this method:

    Code (csharp):
    1.  
    2. TPHelper helper = GetComponent<TPHelper>();
    3. helper.OnTextureChange("texture_name");
    4.  
    and if you need to switch atlas also

    Code (csharp):
    1.  
    2. TPHelper helper = GetComponent<TPHelper>();
    3. helper.SwitchAtlas("atlas_path");
    4.  
     
  41. SealSoul

    SealSoul

    Joined:
    Apr 8, 2014
    Posts:
    3
    Thank you very much.
     
  42. pea

    pea

    Joined:
    Oct 29, 2013
    Posts:
    98
    Hi there!

    First off thanks. I'm evaluating the free version of the importer, together with TexturePacker v3.3.3. I keep getting "No Atlas Found".

    I have to choose between two types of Data Format in TP:

    1. Unity - JSON data (.txt)
    2. Unity - Texture2D Sprite Sheet

    I choose #1, JSON data. Then I publish to my Unity Assets/_Textures folder. When I then select a Mesh object and attach the "TPMesh Texture Ex" script the "TPHelper" says "No Atlas Found". I can see the atlas PNG and JSON TXT files in the Assets/_Textures folder.

    Any ideas?
     
    Last edited: Apr 24, 2014
  43. nkhajanchi.mg14

    nkhajanchi.mg14

    Joined:
    Mar 6, 2014
    Posts:
    13
    Hi,

    I am working on a 2d game where I need to access some images from a sprite sheet atlas. I saw your plugin on Unity Assets Store. It looks impressing but when I tried it found lack of documentation. Yes, you have provided documentation but that's not enough I guess. Documentation provided is mainly of editor only and for scripting part only OnGUI stuff have been covered.

    For getting the image from atlas you have shown the following example. But when I tried it and created a texture and displayed it on screen, I found that draw calls were not reducing.

    TPAtlas atlas = TPackManager.getAtlas(MyAtlasName);
    TPAtlasTexture texture= atlas.getTexture("myTextureName");

    What I want is to get TPAtlasTexture or Texture2D or Sprite type components which I can add to newly created GameObject component and which I can draw without OnGUI method.

    I would be really grateful if you can help me out this thing.

    Thanks
     
  44. nkhajanchi.mg14

    nkhajanchi.mg14

    Joined:
    Mar 6, 2014
    Posts:
    13
    I also tried the following code, it draws two textures on screen, using OnGUI method. But draw calls are also 2 and no saving in draw calls.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Script1 : MonoBehaviour
    5. {
    6.     TPAtlas atlas;
    7.     TPAtlasTexture texture;
    8.     TPAtlasTexture texture2;
    9.    
    10.     void OnGUI()
    11.     {
    12.         texture.draw(0, 0, 80, 80);
    13.         texture2.draw(100, 0, 80, 80);
    14.     }
    15.                          
    16.     void Start ()
    17.     {
    18.         atlas = TPackManager.getAtlas("my_atlas");
    19.         texture = atlas.getPngTexture("mytex1");
    20.         texture2 = atlas.getPngTexture("mytex2");
    21.     }
    22. }
    23.  
     
  45. multix

    multix

    Joined:
    Aug 5, 2013
    Posts:
    16
    Hello,

    How can we handle multiple normal maps? Can we put them also together on an atlas? What would be the correct workflow?

    Thanks!
     
  46. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    You have to put those two files (PNG and TXT) into Resources folder so his scripts can load those.

    Also, do you have _data at the end of txt?

    Read carefully the tutorial.
     
  47. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Hello, one question!

    How can I change the sprite opacity and color (via scripting)
     
  48. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    -snip- nevermind
     
  49. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Kobix, yep, you absolutely right.

    Sorry, but this feature is not supported.
     
  50. AlbertStr

    AlbertStr

    Joined:
    Feb 12, 2014
    Posts:
    13
    Hello all!

    I'm going crazy with a weird thing that is happening with TP, I'll try to explain hehe.
    I have a projecte with an amount af prefabs created and for the texture atlasses i was using Atlas3D (based on NGUI), now I'm changing to Texture Packer, I like it so much but it seems to be incompatibilities.

    I have removed all the scripts from the prefabs and attached TPMesh Texture Ex. The point is that firstly it is ok, but every time I select the prefab it goes crazy and break the texture, I seems that is...reducing the UVMap :/ like I post here in the images.

    Original prefab
    Captura de pantalla 2014-06-13 a les 10.00.48.png

    One Click
    Captura de pantalla 2014-06-13 a les 10.00.55.png

    Two clicks
    Captura de pantalla 2014-06-13 a les 10.01.00.png

    When this happens I go to Blender and resave the file and corrects the error. But If i click again i breacks again -_-
    I've been near to 10 hours trying to solve it, but I've not been able to do it.

    Any idea??

    Thanks!
     
    Last edited: Jun 13, 2014