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

[RELEASED] Free & Open Source Unity PSD Importer

Discussion in 'Assets and Asset Store' started by playemgames, Jul 1, 2014.

  1. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Hey everyone! I and TheRealBanbury worked on a PSD Importer so you can take the layers from your PSD image files and make them into Unity Sprites! This can help with setting up GUI's, laying out backgrounds or characters for 2D games and more!

    Take a look at it here:

    https://github.com/Banbury/UnityPsdImporter

    or my fork here:

    https://github.com/playemgames/UnityPsdImporter

    upload_2014-6-30_20-32-59.png

    Unity Psd Importer is an addon for Unity3D. It provides an editor window from which individual layers can be selected and exported. The layers are exported either as individual PNGs or as an atlas image.

    To compile the Unity PSD Importer in the Unity3D Editor you must have the files gmcs.rsp and smcs.rsp with "-unsafe" in the first line of the files in the root directory of your project. Otherwise you can compile the code as a DLL and it will also work in the editor.

    To use the Unity PSD Importer, in the Unity3D Editor go to Window > Sprites > PSD Import to access the importer, then drag and drop or search for the PSD file you wish to import.

    To only export the layers to PNG files, click on the "Export Visible Layers" button and it will only create the PNG files with the sprites that are visible. You can individually check which layers you want to import.

    To create a root gameobject with all the layers as child sprites and the layers compiled in an atlas, click on the "Create atlas" button. All the layers will be saved to an atlas texture with sprites as children that is autogenerated with the atlas size you define under "Max. atlas size". A root gameobject with the filename of the PSD file is created and all the layers as sprites will be as children gameobjects under the root gameobject.

    To create PNG files individually with each sprite assigned to the PNG files, click on the "Create sprites" button. This will create a root gameobject with the filename of the PSD file and all the layers as sprites under the root gameobject.

    All sprites are created with a center pivot so that they will import in their correct alignment with the PSD file layers' positions.

    Some notes on the PSD support:
    • It should support all image layers, however text, layer groups, or other special layers will not be supported. It is best to flatten layer groups and text before importing.
    • All the imported layers should be imported at their same positions as in the PSD file.
    • When importing as an atlas, if the layers cannot collectively fit in the atlas they will be scaled down to fit the atlas texture, therefore it is preferable to import the layers using "Create sprites" to have the layers imported as separate PNG files.
    If you need help with support for the Unity PSD Importer, please include a project with the files that need testing for debugging, otherwise it's hard to find out what the problem is!

    Don't expect this up on the Asset Store as we want to keep this open to the community and free for everyone to use, so please contribute where you can!

    Also please check out Unity Sprites and Bones that I'll be contributing to here:

    https://github.com/Banbury/UnitySpritesAndBones

    This is made by TheRealBanbury to help make 2D skeletal animation an easier process for Unity users, please contribute to open source by working together to help make great free tools for everyone to use! Thanks for the support!
     
    Linc1987 and jc-drile77 like this.
  2. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    Look interessing Thank's ! :)
     
  3. divas1980

    divas1980

    Joined:
    May 19, 2013
    Posts:
    9
    hi, i have try your asset but dont work..when i select a file psd there is a error:

    VerificationException: Error verifying PhotoshopFile.Util:SwapBytes (byte*,int): Unmanaged pointer is not a verifiable type at 0x0008
    PhotoshopFile.PsdBinaryReader.ReadInt16 () (at Assets/PhotoShopFileType/PsdFile/PsdBinaryReader.cs:72)
    PhotoshopFile.PsdFile.LoadHeader (PhotoshopFile.PsdBinaryReader reader) (at Assets/PhotoShopFileType/PsdFile/PsdFile.cs:187)
    PhotoshopFile.PsdFile.Load (System.IO.Stream stream, System.Text.Encoding encoding) (at Assets/PhotoShopFileType/PsdFile/PsdFile.cs:77)
    PhotoshopFile.PsdFile..ctor (System.String filename, System.Text.Encoding encoding) (at Assets/PhotoShopFileType/PsdFile/PsdFile.cs:63)
    PSDEditorWindow.OnGUI () (at Assets/PhotoShopFileType/Editor/PSDEditorWindow.cs:59)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/monoAndRuntimeClassLibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    i have try to import some psd files but idont work.
     
  4. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    Make sure layer groups are merged or flattened and vector based text is rasterized. Outside of actually seeing the PSD files, I can't help further than that.
     
  5. vorp

    vorp

    Joined:
    Aug 30, 2013
    Posts:
    10
    I had the same problem and it was unrelated to the Photoshop file.
    Try deleting your Library folder and letting Unity regenerate it.
    I have run into issues getting Psd Importer working along side Sprites & Bones on Mac.
    They throw duplicate Assembly Attribute errors and I think it disables Psd Importer from then on.
    I fixed it by rebuilding that Library folder. Then Psd files, even with group layers, come in fine.
    -Len
     
  6. madclouds

    madclouds

    Joined:
    Nov 6, 2013
    Posts:
    31
    Thanks Vorp! I had converted a few PSD's with this awesome plugin, then I started getting SwapBytes error. Rebuilding my Library folder fixed the problem!
     
  7. babelbrian

    babelbrian

    Joined:
    Jul 14, 2015
    Posts:
    11
    Thanks, but can anyone direct me as to how to compile this stuff? In MonoDevelop?
     
  8. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    Is there an update for this.. we need a compiled version.
     
  9. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    So it's an importer and exporter.. Hmm.. I'm not sure how useful this would be as you'd do the export in photoshop. What would be 1000x more useful is if you could import a PSD and flag which layer/s you want to use directly without the need to export.
     
  10. Linc1987

    Linc1987

    Joined:
    Feb 3, 2017
    Posts:
    1
    test good ,FAB Addon,very creative!!!!!!
     
  11. gerrard-pathfinder

    gerrard-pathfinder

    Joined:
    Jun 23, 2016
    Posts:
    1
    Hi I have a question,
    I used your psd file Import tool, and i think awesome tool !

    But I want to some Layer's type.

    For example my psd file has Text Layer or not.

    How can I know or get Information of Layer Type by your tool or your tool's code ?
     
  12. playemgames

    playemgames

    Joined:
    Apr 30, 2009
    Posts:
    438
    You have to rasterize or flatten the text layers in your PSD before hand to make them into sprites.
     
    theANMATOR2b likes this.