Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Official 2D PSD Importer is out of preview for 2019.3

Discussion in '2D' started by rustum, Jan 30, 2020.

  1. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    2D PSD Importer.png
    From 2019.3 onwards the 2D PSD Importer package is out of preview and verified. This means that the 2D PSD Importer package is stable and will receive regular bug fixes. It is ready for production. We will continue to add new functionality and this will be clearly marked as experimental to distinguish it from the more stable features.

    Overview
    The PSD Importer is a custom Asset Importer made to import Adobe Photoshop’s PSB files into Unity. The PSB file format is functionally identical to the more common Adobe PSD format, with the additional ability to support much larger images than the PSD format (up to 300,000 by 300,000 pixels in size).

    Users saving or converting their PSD working files to the PSB format can import their work with the PSD Importer, and take advantage of the additional functionality and features provided by the importer.

    Getting Started
    1. Install latest Unity 2019.3
    2. Open Package Manager by going to Window > Package Manager
    3. Choose 2D PSD Importer from the list and click on Install at the bottom right of the Package Manager window. 2D PSD Importer in Package Manager.png
     
    Foxaphantsum, EvOne and Deleted User like this.
  2. Foxaphantsum

    Foxaphantsum

    Joined:
    Jul 5, 2013
    Posts:
    139
    So far I love this. I've been using it as a reference for building my own SpinePSDImporter.

    One issue I was concerned about. If you change the name of a group or layer in the PSB the sub assets in the project reflecting them in the view won't refresh unless

    A) you close and then re-expand the parent game object
    B) You Add or Remove sprites/groups in the PSD file.

    I feel like this may be an issue with how AddObjectToAsset works within the AssetImportContext


    This would be great to have a fix for and or a work around if possible.
     
  3. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    A PSD-Importer that does not support PSD? o_O
    What about naming it PSB-Importer?
     
    Last edited: Feb 19, 2020
    Vivien_Lynn, EvOne and Martin_H like this.
  4. Foxaphantsum

    Foxaphantsum

    Joined:
    Jul 5, 2013
    Posts:
    139
    I assume that's because Unity already has a limited native psd importer and doesn't yet allow us to override existing importers. (something I hope will come in future)

    Currently my work around for my issue above with refreshing the renaming was by creating a static toggle variable for the Importer that I switch on and off every import.

    example
    Code (CSharp):
    1.             if (toggle) {
    2.                 var temp = new GameObject();
    3.                 temp.name = "temp";
    4.                 ctx.AddObjectToAsset("temp", temp);
    5.             }
    6.             toggle = !toggle;

    But this is so hacky and won't work all the time with more then 1 psb since multiple at the same time will toggle the toggle.

    I can of course look into ways to work around this but... I'd rather see if there is a better solution then dive into that rabbit hole.


    Edit*

    I've provided a bug report on this issue too
     
    Last edited: Feb 19, 2020
  5. needs_glue

    needs_glue

    Joined:
    Dec 14, 2016
    Posts:
    1
    I have just started testing this in 2019.3.1f1, currently on a multilayer PSB changing the pivot in the inspector doesn't seem to be working for the individual sprites, if individually changed through the sprite editor it is working though.
    Is this expected behaviour when dealing with PSB import with the following settings?
    Texture Type: Sprite (2D and UI)
    Sprite Mode: Multiple
    - Mosaic
    -Character Rig
    (any of the non centred pivot options)

    For the number of sprites in the .PSB I was hoping for a way to handle these in a batched process.
     
    EvOne likes this.
  6. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    It's probably a bug! We will look into it. Thanks for reporting.
     
    needs_glue likes this.
  7. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Yes we are aware of the issue. Unfortunately, this is due to the new AssetDatabase V2. We have the a bug case for it already and the team will get to it as soon as they can.
     
    Foxaphantsum likes this.
  8. Wynellrussell

    Wynellrussell

    Joined:
    Apr 28, 2020
    Posts:
    3
    Keep in mind though, that Unity recommends those with projects already in production wait for the release of Unity 2019.4 Long-Term Support (LTS) which will land in spring. If you’re about to embark on a new project though, have at it!


    kohi click test
    click speed test
    facebook video downloader
     
    Last edited: Apr 29, 2020
  9. ScionOfDesign

    ScionOfDesign

    Joined:
    Oct 6, 2016
    Posts:
    82
    Hey so in our Photoshop file we have many different eyes/facial expressions and we would like to use the Sprite Swap experimental feature to swap between expressions. The issue is that when using the sprite library the sprites don't maintain their relative positions because all of their pivots are centered.

    To work around this in Photoshop, we tried making each expression is a smart object that has the same canvas size. However it seems that photoshop automatically trims smart objects to their smallest size based on transparency. This results in objects being imported with trimmed dimensions and a centered pivot, when what we want is for all the objects to have the same sprite dimensions.
    upload_2020-6-6_14-35-37.png

    Is there something that you could do to allow the importer to import smart objects using their real resolution, as opposed to their trimmed resolution?
     
    Vivien_Lynn, Rafarel and EvOne like this.
  10. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    Hi @Filiecs
    Thanks for trying out the experimental Sprite Swap feature!
    Have you tried setting each sprite's pivot in the Sprite Editor Window?
     
  11. ScionOfDesign

    ScionOfDesign

    Joined:
    Oct 6, 2016
    Posts:
    82
    This would work if we did it manually, or wrote our own tool to set the appropriate pivot point based on some external data, however all those custom pivots could be completely destroyed if we need to re-slice the PSB. It would also require some very precise calculation for each and every single sprite. The process should be, and can be, automatic.

    Having the option to have the importer use the 'real' size instead of 'trimmed' size for smart objects would be one semi-fix.
    What I mean is that even if I have a smart object that has a canvas size with padding:
    upload_2020-6-8_16-50-6.png

    Photoshop will automatically trim all the whitespace around the object when calculating the size in the main file and thus the object will import into Unity as trimmed.
    upload_2020-6-8_16-52-6.png

    Another, better, option could be as follows:
    Currently when you assign a group of sprites a category in the sprite swap panel, it combines all of their individual objects into a single object that simply has its sprite swapped. This loses any specific positioning information you may have wanted on an individual sprite beforehand.
    You can instead have the new single object's transform position be the average position of all the objects in the category. Then you can use all the objects in the category and calculate a maximum bounds for them.
    Using the new average position, the maximum bounds of the category, and the original position of the object in the PSB you can then calculate what the objects pivot should be in order to maintain the same position as it was in the PSB when the sprite is swapped.

    Having this optional ability to automatically calculate and set the pivots for sprites used in the sprite library, so that the sprites maintain the same position as they were in the PSB, would be invaluable. So would having the ability to import smart objects with custom margins like above.
     
    EvOne likes this.
  12. hazel_koop

    hazel_koop

    Joined:
    Apr 9, 2019
    Posts:
    29
    Is there any way to either
    1) change the default Max Texture Size for new assets, or
    2) change an asset's Max Texture Size from a script?
    I can't find the property that I'd need to change on the PSDImporter object (or what else I'd need to cast the assetImporter to, if not that)
     
  13. sschoellhammer

    sschoellhammer

    Joined:
    Feb 15, 2013
    Posts:
    46
    I love this feature, it's very well thought out and the work flow is really user-friendly.

    Sadly the packing quality is a deal breaker for me. Is there really no influence on the packing or am I missing something? I checked the code and I don't see any options .. I'd love if one could at least pack it manually but this I just cannot use.


    upload_2020-7-16_18-19-48.png
     
  14. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Hi, the PSDImporter pack is pretty rudimentary. To have a tighter pack, you can use SpriteAtlas.
     
  15. sschoellhammer

    sschoellhammer

    Joined:
    Feb 15, 2013
    Posts:
    46
    @Leo-Yaik
    but this defeats a lot of the purpose of the tool right? Setting up the prefabs, moving them to the right spot etc. Why would I use it in the first place if the packing doesn't work for me?
     
  16. sschoellhammer

    sschoellhammer

    Joined:
    Feb 15, 2013
    Posts:
    46
    @Leo-Yaik sorry to be a pain, but again. What's the use of the whole psd importer if you can't control the packing?
     
  17. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    As mentioned, SpriteAtlas will be a better candidate to tackle packing as it has better controls instead of having 2 systems that tackles similar problems.
     
  18. RINNUXEI

    RINNUXEI

    Joined:
    Sep 3, 2015
    Posts:
    32
    Hey, good job with this.

    Though we found a problem that, the texture format for sprites within the imported psb asset can be different from the Platform Settings. In Platform Settings, all platforms are the same as the Default one, which uses RGBA 32 bit format. However, when we switch to iOS platform and try calling GetPixels from those textures, it throws Cannot access pixel data of compressed texture formats which cannot be partially decompressed (such as Crunch). It turns out that the real texture format changes to PVRTC_RGBA4, despite the default setting in Platform Settings.
    By the way, if we check Override in Platform Settings to force it to use RGBA 32 bit explicitly, we can now call GetPixels without any errors.

    Is this a bug or are we missing something? We are using Unity2019.4.1f1 and the PSD importer version is 2.1.4.
     
    Last edited: Aug 31, 2020
  19. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    It sounds like a bug. Can you report it so that we can keep track of it.

    Cheers
     
  20. Romano

    Romano

    Joined:
    Nov 27, 2013
    Posts:
    76
    How easy would it be to have an option for photoshop folders to import as empty game objects? This is how my PSD imports just one face (there's more I need to add still):
    upload_2020-9-11_12-1-24.png
    Using game objects as folders would help a whole lot with organisation and animation.
     
    EvOne likes this.
  21. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    Is it possible for the PSD importer to support .psd files? Would be lot less hassle to use because I cannot use .psb and I have to manually convert back and forth everytime I want to make a change.

    Edit: What I mean by supporting .psd files is to be able to use individual layers inside the .psd file.
     
    Last edited: Oct 8, 2020
  22. Rafarel

    Rafarel

    Joined:
    Jul 21, 2017
    Posts:
    199
    Hi @Filiecs , I think I'm in the same case as you. I have a character that I want to animate with hybrid techniques the the body and arms will be rigged with bones but the ayes are separated sprites like for eye blink. So I have one torso on my PSB file but many eye layers stacked on each other but sorted in groups (see screenshot below). For eyes animation I just want to swap the eye sprites but the issue is they don't share the same pivot. I would be great if all sprites of a same group could share the same pivot... I heard about sprite swap feature but can you tell me more about this ? How did you manage you eye animation at the end ? Have a nice day !


    upload_2020-12-3_12-46-8.png
     
  23. JuliaKaren

    JuliaKaren

    Joined:
    Sep 11, 2022
    Posts:
    1
    Last edited: Sep 11, 2022
    KylieLauren likes this.
  24. KylieLauren

    KylieLauren

    Joined:
    Sep 11, 2022
    Posts:
    1
    yes it's so amazing feature you must try it
     
    JuliaKaren likes this.