Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

PSD Importer?

Discussion in '2D Experimental Preview' started by Aygtets, Dec 2, 2018.

  1. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    I analyzed the size of the assets using the Editor.log. The *.psb asset seems to be the same size with and without packaging in SpriteAtlas. Ok thanks, I'll use this workaround to use multiple atlas sheets.
     
    Ted_Wikman likes this.
  2. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    I do a PSB import (with "Use a Rig", "Use Layer Group", "layer Mapping: Use Layer ID" properties) and get a prefab. Then I add components to objects (such as animation, particles, custom behaviors) in this prefab. If after that I rename one of the PSB layers, then inside the prefab all components will be deleted from this object. Is this the expected behavior?
    PSD Importer v 6.0.3
     
  3. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
  4. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    @MaximPP your video shows one thing and your explanation here says another.
    Could you give us a bug report with what goes wrong and steps to reproduce the issue(s)?
     
  5. MaximPP

    MaximPP

    Joined:
    Jan 26, 2019
    Posts:
    76
    My last two posts are two different bugs. The video shows how some of the lines disappear when the layers are merged. Okay, I'll submit these issues as a bug report.
     
    Ted_Wikman likes this.
  6. prokhorvlg

    prokhorvlg

    Joined:
    Sep 12, 2021
    Posts:
    6
    Hey! Took me a while as I had to wait for the latest Unity update.

    I finally tried this and unfortunately it does not appear to solve the issue in its current state. It does increase the padding between the sprites which is a step in the right direction, but the "Extrude Edges" value that should increase the size of the meshes beyond the edges of the sprites does not do anything. I have looked up the issue and have not been able to find a solution to this. Perhaps I am missing something.
     
  7. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    @prokhorvlg I believe the feature you are looking for is Sprite Padding, which we just released in PSD Importer 8.0.0 (Unity 2022.2).
    Have a look at this image to see the difference between Mosaic Padding and Sprite Padding

     
    Last edited: Jun 7, 2022
    JonPQ and prokhorvlg like this.
  8. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    We tried using PSD importer for props and characters when building level maps. But have a problem with props. For example when building a tree... we use one sprite for the trunk, and then one sprite duplicated say 5-10 times for the leafy part of the tree. But PSD importer will duplicate the bush 10 times in the texture sheet, instead of it appearing just once, bloating the memory. Is there any way to avoid this duplication please?
     
  9. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    @JonPQ any chance you could share this .psb/.psd with me so I can take a closer look at what is going on?
    Thanks!
     
  10. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    Thanks for taking a look.
    yes, here is an example... photoshop file... (sent to you separately) only 2 sprites, pasted into 2 groups, of 5 layers.
    2 are unscaled and not-rotated ( the large mushrooms, are identical ) the small mushroom just has a small scale but is the same sprite. The two grasses are the same sprite, at same size, but one has a rotation....
    If building these prefabs by hand in unity... they would still only use 2 sprites... and you could build a whole host of prefabs out of a small number of sprites in this way...
    upload_2022-7-1_9-48-58.png

    However, psd importer does not recognize that the layers are using the same sprite... and quickly fills up the texture sheets with duplicate images.... Ideally, the importer should be able to recognize that the source image is the same, and just use one image each in the sprite sheet. ( one mushroom, and one grass )
    upload_2022-7-1_9-51-2.png

    I understand this would be difficult to achieve if the same sprites are re-used in a separate .psd file... but within a single psd file import, it should be do-able, useful and a great texture/memory optimization.

    It would also speed up the artist pipeline process, props are currently built... exported, imported as separate png's then manually put back together in unity, one sprite and prefab at a time. if PSD-importer, could import without the duplicates... the props could all be imported at once from a single psd in one single import action.
     
    Last edited: Jul 1, 2022
  11. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Thank you for sharing both some screenshots and the actual .psb so I could have a closer look. I understand where you are coming from, and what you would like to see. However, from the PSD Importers "point of view", it sees 5 layers with image data, and will therefore create 5 individual Sprites. It does not know that some of the layers contains the "same" Sprite, but transformed. I am not quite sure how we would go about identifying that two PSD layers could make use of one Sprite and just transform it in order to get the same end result.

    I'll note this piece of feedback down so that we can consider it in future PSD Importer improvements.
     
    JonPQ likes this.
  12. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    Thanks for the quick reply, yes I suspected that that would be the answer, but I thought I'd ask anyway as it would be so useful to many I think.
    I suppose it depends what information you have access to in the PSD file... If you know the source image file info/path ( sprite ) conceivably you could find duplicate images across layers... then if you have rotation and scale, you could apply that to the generated gameobject in unity instead of to the image import or spritesheet uv's... I guess it also depends on if the image loads in as already flattened and transformed or not.... if that is the case, then as you say..... would be very difficult to do.
    Is the psd importer source code available ?
    Thanks for the clarification.
     
  13. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    As a simple experiment, I created two .psb files. One with a single box, and another one with the single box duplicated (so two layers with identically sized boxes). The file size for the single box .psb comes in at 175 KB and the file size for the 2 boxes comes in at 238 KB. This means that the image data per layer is duplicated, rather than using a lookup table for identical layers in a .psb/.psd file.

    The source for the PSD Importer is open and fully viewable and editable in the PSD Importer package folder, so feel free to experiment with the code and do let me know if you make any interesting discoveries. The parsing of a psd/psb file is using a heavily modified version of PsdPlugin. The source is also viewable and editable in the PSD Importer package.
     
    JonPQ likes this.
  14. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    Thanks for trying that Ted :) much appreciated. I'll let you know if I get anywhere.

    ...update...-> I'm not currently working on this... but if I get back to it, I'll post update...
     
    Last edited: Sep 26, 2022
    Ted_Wikman likes this.
  15. Jointy87

    Jointy87

    Joined:
    Dec 19, 2019
    Posts:
    21
    Is there a way to achieve something similiar to either of these options using PSD importer 6? What would a viable workaround be?

    EDIT: I'm looking for this because in PSD importer 6 the cutouts in the sprite editor of each layer are put so close together I get a lot of artefacts on the edges of the cutouts from the layer next to it.
     
    Last edited: Apr 10, 2023
  16. Jointy87

    Jointy87

    Joined:
    Dec 19, 2019
    Posts:
    21
    To add more info to my problem mentioned above: My sprite is showing artefacts like this:
    upload_2023-4-10_20-53-17.png

    And this seems to be because the PSD importer 6 automatically slices layers and puts them too close together so you'll often get a piece of the next layer in your sprite.

    upload_2023-4-10_20-54-36.png

    I've played around with all import settings and I can't get this resolved. What would be a valid workaround for this? Updating to Unity 2022.2 Tech Stream isn't an option so late in development.

    Cheers.
     
  17. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    @Jointy87 can you share your source image for us to take a look? You can PM me the file.
    There should be pixel padding between each layer and from image you showed, it seems like the padding wasn't applied.