Search Unity

Texture Packer + Unity Tutorial

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

  1. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello. Thanks for report. I will try to fix it ASAP.
    Cheers!
     
    AlbertStr likes this.
  2. AlbertStr

    AlbertStr

    Joined:
    Feb 12, 2014
    Posts:
    13
    Hello!
    We have all the scene mounted with Texture Packer. In the meshes that have overlapping we are using a scond UVMap for the lightmapping.
    The problem is that when we bake the scene, all the props that has the same "TexturePacker mesh" have the same shadows. For example, we have a Tree mesh, texturepacker assing Tree_uvs to the mesh renderer, when we bake the scene alla the Tree_uvs hace the same shadows baking. Is there any solution?

    Thanks!
     
  3. awardell

    awardell

    Joined:
    Feb 5, 2014
    Posts:
    71
    Hey Lacost, what exactly does Replace Material do? I know you say to turn it off if we want to use a different material with a different shader on a mesh, but what exactly is the benefit of having it on?

    EDIT: Actually, could you explain Clone Material as well? Thanks!
     
  4. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello.
    It will use the initial matters for all meshes that use the same atlas. basically it will meet requirements for dynamic batching. So the benefit - you will have less draw call.

    The new material for each mesh will be instantiated in awake. Useful if you have a lot fo sprites and you whant to be able to change it color without affecting others.
     
  5. awardell

    awardell

    Joined:
    Feb 5, 2014
    Posts:
    71
    Thanks for the reply!


    But isn't that taken care of when I apply the component? When I apply the component, the object is given the initial material. If I turn off "Replace Material", it still uses that same material unless I manually change it, right? So even with "Replace Material" turned off, it will still dynamic batch, if I'm understanding correctly. Is "Replace Material" just a failsafe in case the material is accidentally changed?

    If you modify renderer.material, Unity makes a copy of the material anyways, so what is the point of this?
     
  6. stanislav-osipov

    stanislav-osipov

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

    Thanks for info. But if you modifying initial material without accessing renderer.material, it will change all objects with has this material applied.
     
  7. Varionic

    Varionic

    Joined:
    Jul 25, 2014
    Posts:
    2
    Does anyone know if there's a tutorial for using TexturePacker with animated particles?
     
  8. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    You can nor use plugin to apply atlased texture to the particle system, scince it doesn't have mesh renderer component.
     
  9. Varionic

    Varionic

    Joined:
    Jul 25, 2014
    Posts:
    2
    I'm talking about the particle systems that use meshes.

    Particle system>
    Renderer>
    Render Mode > Mesh
     
  10. kurismakku

    kurismakku

    Joined:
    Sep 18, 2013
    Posts:
    66
    Hi, lacost ! :)

    I am trying to use your plugin, but I am not really sure how to use it for what I want, so maybe it is not even possible.

    I placed test_data.png and test_data.txt inside of the Resource folder.
    I am calling this in script :

    var atlas:TPAtlas = TPackManager.getAtlas("test_data");
    var texture:TPAtlasTexture = atlas.getTexture("medal_wac_1st");

    But I get error in second line, when trying to acess atlas because it is null.

    One more question, can I use TPAtlasTexture after that for GUI.Button?

    Thanks :)
     
  11. reformy

    reformy

    Joined:
    Nov 8, 2012
    Posts:
    8
    Hello!
    I am looking for something quite simple...:
    I've created a sprite texture and set an image from my atlas to it.
    Now - how can I programmatically change the image to another in the atlas (using its name)?

    Thanks
    Yair
     
  12. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hey. kurismakku. The plugin API is C# only, so it's impossible to use it via JS. Sorry.

    Sure, here is the example.
    Code (CSharp):
    1. public TPHelper helper;
    2. if(!helper.atlasPath.Equals("my_atlas_name"))  {
    3.                 helper.SwitchAtlas("my_atlas_name");
    4.             }
    5.            
    6.             helper.OnTextureChange("my_texture_name");
     
  13. niall1111

    niall1111

    Joined:
    Nov 29, 2013
    Posts:
    14
    Hi lacost, this plugin seems like it might work for our purposes, but it seems no one has done exactly this...

    We have sprite sheets created by TexturePacker in .pvr.ccz format, for cocos2d in xcode, along with a .plist output file. The sheets are downloaded at runtime, for displaying one of many children's books with animations. I want to use these sheets in Unity as part of a porting project i'm doing. I can obviously convert the sheets to .png format in TexturePacker, but will the plugin allow me to load these sheets at runtime, and create individual sprites from them, with the caveat that the sheets will not be part of the Unity project, they are downloaded as .zip files, extracted, and stored in Application.persistentDataPath, and therefore can't be used with Resources.Load.
     
  14. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Yep, you can load atlases in runtime, and plugin contains the example scene with show how to do this
     
    niall1111 likes this.
  15. Object-Null

    Object-Null

    Joined:
    Feb 13, 2014
    Posts:
    70
    Hello,
    i bought the Pro Version of Texture packer. but i'm using the pro version of unity.
    In your document you can see in your tutorial "AtlasesAnim" that you only get 1 drawcall.
    When i open your project in my latest unity i get 175 Drawcalls. (with the Free and the Pro version of Texture packer).

    what could be the problem here? before i start with my project i wan't to know what it all does. And the tutorial is not the same in my project.

    edit: i set the texture from transparant/diffuse to unilit/transparant, then i got 2 drawcalls
     
    Last edited: Aug 12, 2014
  16. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Sorry for slow replay, I need to see your project to find out want goes wrong, I believe we already in touch by e-mail.
     
  17. Peppercat

    Peppercat

    Joined:
    Oct 23, 2012
    Posts:
    6
    I've got the free version, and I'm getting the following errors when trying to open the texture packer tab in Unity Editor:

    Atlas Can not be loaded form: F_02 - UnitySS
    KeyNotFoundException: The given key was not present in the dictionary.

    I did my atlas in Texture Packer application and loaded it in my Resources folder (F_02 - UnitySS.png and F_02 - UnitySS_data.txt). What did I do wrong? Thanks!

    (Tell me if you need the screenshot)
     
  18. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Can you please send this issue example as archive or package to stans.assets@gmail.com It's hard to tell what goes wrong using just exception type.
    Cheers!
     
  19. Peppercat

    Peppercat

    Joined:
    Oct 23, 2012
    Posts:
    6
    Ok, I'll send it, thanks for answer!

    EDIT: Sended you a MEGA link. Hope you can download and try it. Thanks!
     
    Last edited: Aug 26, 2014
  20. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Thanks got it :)
     
    Peppercat likes this.
  21. reformy

    reformy

    Joined:
    Nov 8, 2012
    Posts:
    8
    Hi all
    Can someone please help me with this issue:
    When playing, I create tpsprite objects at far, and move them toward the camera. They all use the same atlas (under resources/atlases).
    The problem is that sometimes, "distant" objects (with higher z) are drawn on top of "closer" objects.

    How can I fix this?

    Thanks,
    Yair
     
  22. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Well plugin is't affect object Z positing or rendering (it only changes mesh UV), so it's not connected with the plugin for sure...

    Cheers!
     
    reformy likes this.
  23. reformy

    reformy

    Joined:
    Nov 8, 2012
    Posts:
    8
    Another question:
    I am running my game in android and ios.
    If I put 2 atlases under "Resources", when the scene is loaded, will these 2 be loaded to memory always?
    If I have only one sprite in the scene that uses one of them, will they still both be loaded to memory?
     
  24. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    If atlases in resources, it mean that they will be in the build. But it will be loaded in the memory only when object with use atlas is on the scene. In other words:

    No, only one that used by your sprite.

    Cheers!
     
    reformy likes this.
  25. ButtReynolds

    ButtReynolds

    Joined:
    May 16, 2014
    Posts:
    5
    Heylo, thanks for the great importer.

    When I attach the TPSkinnedMeshTextureEX script I get an error "Bones Do Not Match Bind Pose" and the model does not seem to be skinned anymore. If I turn on "Use Shared Mesh" the animation works but I still get the red warnings. Seems to build with no problems, but should I worry about that error?

    I think it might be related to the model import. I have "optimize game objects" turned on which removes the bones when I place it into the scene.
     
  26. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Yea I guess this is the issue, But if you will send me your project I guess I can look for solution. Please use stans.assets@gmail.com mail.
    Cheers!
     
  27. ffman22

    ffman22

    Joined:
    Oct 7, 2014
    Posts:
    36
    can we use only 1 sprite of the sprite sheet for create a material for a particle ??
     
  28. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    The particle sprites doesn't have MeshRenderer component so it can't be used with TexturePacker unfortunately.
     
  29. fancybit

    fancybit

    Joined:
    Sep 6, 2012
    Posts:
    3
    I exported the atlas from texterpacker to unity project, there are .txt and .png file in the resources folder but why I can't see the new atlas in Texture Packer window in u3d?
     
  30. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
  31. CRIK

    CRIK

    Joined:
    May 13, 2013
    Posts:
    6
    Hi lacost,

    When I open tutorial project "AtlasesAnim" in unity(4.6.1f) I got 155 Drawcalls.
    (Free and the Pro version of Texture packer).

    What's wrong?
     

    Attached Files:

  32. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Hello, in order batching to work, all requirements described here should be completed:
    http://docs.unity3d.com/Manual/DrawCallBatching.html


    Texture Packer will help you to use same material for most of your objects, which is most important bitching condition.
    Try to change pixel lights count in your projects settings.
     
  33. CRIK

    CRIK

    Joined:
    May 13, 2013
    Posts:
    6
    Thanks lacost.
     
  34. asad_asm

    asad_asm

    Joined:
    Oct 17, 2014
    Posts:
    23
    CPU optimisation can be achieved by reducing Draw Calls count by Draw Call Batching. But Draw Call batching only possible with objects sharing same material.

    Material Converter helps you to prepare a shared material from two or more identical materials which differ only in textures and colours. It combines different textures into a texture atlas that can be used by shared material.It auto remaps mesh's uv into texture atlas.

    Material converter is available in the assetstore http://u3d.as/3fn
    Also visit http://support.spinoffstudio.com/Material_Converter.html
     
  35. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    214
    How to setup atlas and texture switch references for different screen resolution? If I use scale variant in texture packer?

    This feature is easy in NGUI but without?
     
  36. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
  37. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    214
    Thank you, I solve my problem and it is easy.

    Texture packer export me scale variant in Resources folder. I detect screen size and load sprite atlas and modifiy reference in my UI and Sprite.
     
  38. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    glad to hear that :)
     
  39. normandguerin

    normandguerin

    Joined:
    Sep 1, 2014
    Posts:
    12
    Here is a link to an online free sprite packer built for unity3D 5. Just make sure the files you upload are all the same naming convention with leading zeros like. frame01, frame02, frame03,,, frame10 and so on. Also you upload a zip file which is very usefull.

    http://normandguerin.ca/tool.php
     
  40. HOOVI

    HOOVI

    Joined:
    Dec 9, 2014
    Posts:
    1
    Hi,
    i have a skinned mesh, with two Textures. How i can do this with the Texture Packer. I have this two Textures on one Atlas.
     
  41. stanislav-osipov

    stanislav-osipov

    Joined:
    May 30, 2012
    Posts:
    1,790
    Sorry but plugin supports only materials with one texture.
     
  42. Ratboy601

    Ratboy601

    Joined:
    Jun 22, 2014
    Posts:
    29
    Hi there, I'm trying to get TPFree working with an atlas exported from Texture Packer Standalone, and the TP Helper script doesn't seem to recognize any data within the data sheet, although it DOES recognize the data sheet itself as atlas data.
    TPFreeError.png

    Also I'm getting the following error messages:
    Atlas Can not be loaded form: CK_ToonTexturesAtlas
    UnityEngine.Debug:LogError(Object)
    TPackManager:load(String)
    TPackManager:getAtlas(String)
    BaseTPConmponents:get_TextureAtlas()
    TPHelperEditor:OnInspectorGUI() (at Assets/Extensions/TexturePacker/TPCore/Editor/Components/TPHelperEditor.cs:110)
    UnityEditor.DockArea:OnGUI()

    Object reference not set to an instance of an object
    UnityEngine.Debug:LogError(Object)
    TPackManager:load(String)
    TPackManager:getAtlas(String)
    BaseTPConmponents:get_TextureAtlas()
    TPHelperEditor:OnInspectorGUI() (at Assets/Extensions/TexturePacker/TPCore/Editor/Components/TPHelperEditor.cs:110)
    UnityEditor.DockArea:OnGUI()

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,TPAtlas].get_Item (System.String key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    TPackManager.getAtlas (System.String atlas)
    BaseTPConmponents.get_TextureAtlas ()
    TPHelperEditor.OnInspectorGUI () (at Assets/Extensions/TexturePacker/TPCore/Editor/Components/TPHelperEditor.cs:110)
    UnityEditor.InspectorWindow.DrawEditor (UnityEditor.Editor editor, Int32 editorIndex, Boolean forceDirty, System.Boolean& showImportedObjectBarNext, UnityEngine.Rect& importedObjectBarRect, Boolean eyeDropperDirty) (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1211)
    UnityEditor.DockArea:OnGUI()

    I'm not sure if I'm doing something wrong or if TPFree is simply no longer compatible with Unity (I'm on 5.2.0f3) or the most recent version of TP (4.0.0b1). I'd like to upgrade to the paid version if I can get this to work properly, but if I don't have a working example of what it can do, then I'm at a loss.
    =======EDIT============
    I was able to resolve this issue by changing the file type (In TPStandalone) to JSON text format. All was good thereafter. Thanks! So far great plugin! I'm hoping it saves me a ton of performance power.
     
    Last edited: Oct 6, 2015
  43. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi, I am trialing the package but I can't seem to get at he textures for my characters in atlases. I have no problem with sprites for UI elements but the import for my char textures cannot be split. Does the free version allow textures for 3d meshes?

    I will buy the asset if it does what I need but would like to confirm first.

    Thanks

    Andy
     
  44. Ratboy601

    Ratboy601

    Joined:
    Jun 22, 2014
    Posts:
    29
    Hi Andy, I had similar confusion recently, and the short answer is yes. You can use the TPfree plugin for 3d meshes. Just put the script "tp mesh texture ex.cs" on any game object with a mesh filter and a mesh renderer. But if you're not using the Texture Packer standalone to make your atlas OUTSIDE of Unity (exported in Unity JSON format, not 2D sprite packer) then it won't recognize your atlas because it has no coordinates data to reference. Make sure to export the data file with a file name such as "MyAtlas_data.txt" and make sure to name your Atlas the exact same but without the "_data" and make it a .png, i.e. "MyAtlas.png". Export the files directly to your Unity project's Assets/resources folder. And THEN you should be able to select your Atlas from the TPHelper.cs script in your Inspector, and then select the specific texture from the menu below it.

    Hope that helps!
     
    AndyNeoman likes this.
  45. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Thank you for your concise reply.

    Long day crunching and I know the info is in on the website but your explanation is that bit easier to follow after the 15 hours that have stared at a screen today :)

    Saying that I will wait for the new day to try it so apologies in advance if you find a message in the morning. Thanks again. :oops:
     
    Ratboy601 likes this.
  46. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Hi,

    I have done all the above (I think) but the atlas selector is only giving example option. My atlas is not appearing even though I have the _dat.txt file showing and the .png with the same name in the assets directory.

    Any help appreciated. I can select the texture but that just covers the mesh with all the textures on rather than the individual one.
     
  47. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    I have gone over the details again - i do not have a mesh filter (just a skinned mesh renderer) is that a problem?

    Edit I have added mesh filter now and small steps to succes I can now choose the altas. I have done that and picked the correct texture but now the model is just white. Nearly there I think but can someone help me get over the line. Sorry to be a pain btw - appreciate the time.
     
    Last edited: Oct 17, 2015
  48. Ratboy601

    Ratboy601

    Joined:
    Jun 22, 2014
    Posts:
    29
    There is a different script specifically for skinned mesh renderers. I believe it is "TP Skinned Mesh Texture Ex.cs"
     
    AndyNeoman likes this.
  49. AndyNeoman

    AndyNeoman

    Joined:
    Sep 28, 2014
    Posts:
    938
    Thanks for that. I think the software has great potential but instructions seem pretty poor and feedback is slow from the owner.

    Is it possible to manually enter textures in the position you choose or does adding a new texture always move the old ones around meaning you have to reset up in unity etc...

    It is a pain and now 7 days are up the software has locked me out and I cannot use free even though the says there is a free version. I may have to look at an alternative - I don't mind paying for software but this software acts like malware in some respects, does not allow me to click through license page and will not resize for me to look at the bottom of the screen.

    Shame because I do really like it and want to purchase if I can get good feedback.
     
  50. Ratboy601

    Ratboy601

    Joined:
    Jun 22, 2014
    Posts:
    29
    I'm not sure if you're talking about the plugin author or the standalone author. I agree that instructions for Stan's assets in general are poor, probably because English is not his first language, but his response time is good, and I've still been able to figure things out.

    You'd have to play with the settings, I haven't bought either program yet either, and I haven't had to add any new images yet, so you're on your own there. Also we should keep this on the topic of the plugin. If you need support for the standalone, that author has his own support email (and forums I think). Good luck dude!
     
    AndyNeoman likes this.