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
  3. Dismiss Notice

PSDImporter API Request

Discussion in '2D Experimental Preview' started by Leo-Yaik, Mar 26, 2021.

  1. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Hi,

    We have seen several requests to have API access for the PSDImporter. We are looking at adding support for this.

    We would like to hear from you what APIs would like to have for the PSDImporter and how you will be using them.
     
  2. nickfourtimes

    nickfourtimes

    Joined:
    Oct 13, 2010
    Posts:
    247
    On our project, we'd like to be able to at least change the maxTextureSize of the generated sprite.
     
    Leo-Yaik likes this.
  3. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    236
    I'd really like to hook into the API to get associated GameObjects and SpriteRenderers for the sprites that get imported.

    I've been trying to use OnPostprocessSprites, or any AssetPostprocessor really. Tracking down these objects from there has not been working and trying to figure it out has been a bigger time sink than I'd like.

    For now, what I am trying to do is set the sorting layer of the SpriteRenderer.

    I could see myself trying to use this to do some auto-rigging potentially and also adding some custom recoloring components to certain sprites. Or maybe even some deforming to get say a piece of clothing to overlay more perfectly.
     
    Leo-Yaik likes this.
  4. carloss85

    carloss85

    Joined:
    Dec 10, 2015
    Posts:
    3
    Hello, I need methods to quickly change setting by platform, something like the TextureImporter
    Code (CSharp):
    1.  
    2. var androidSettings = importer.GetPlatformTextureSettings("Android");
    3. // .........
    4. // Change settings such as max resolution, format, compression quality etc
    5. // ...........
    6. importer.SetPlatformTextureSettings(androidSettings)
    7.  
    Thank you
     
    tonytopper likes this.
  5. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    236
    Also, working on clothing and layering and finding myself looking for the most efficient and performant way to do this. Not sure UnityEngine.U2D.Animation and PSDImporter APIs currently make this easy. In fact, it is looking to be very much harder than I anticipated.

    Being able to iterate is important to prototyping.

    I'd like to be able to play around with "Order in Layer". I can probably just do this with a naming convention, but it would be nice to have other options. Right now the Importer just stacks the sprites one on top of another, leaving no room to slide other things in

    As well, trying to figure out how a piece of clothing's sprite sheet/rig can be layered over and attached to another underlying rig. Essentially, we need to be able to weave multiple rigs together dynamically.

    upload_2021-12-2_10-45-46.png upload_2021-12-2_10-49-13.png
     
  6. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    236
    Leo-Yaik likes this.
  7. AmeX

    AmeX

    Joined:
    Mar 27, 2014
    Posts:
    14
    I need an option in order to set sprites to the same size of the PSD file, and arranged as a tilemap in spritesheet.
    and need some APIs to set each sprite's pivot whatever they are rigged or not.
    Thanks
     
  8. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Hi, do you mean by you want to control where to place the layer's rasterized data on a specific location of the texture?
     
  9. AmeX

    AmeX

    Joined:
    Mar 27, 2014
    Posts:
    14
    yes, and customize their pivots.
    currently it's not easy to use a psd file as a 2d frame animation source file (each layer or group as a frame).
     
  10. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Thanks for the feedback; keep them coming!
     
  11. stuartjeff

    stuartjeff

    Joined:
    May 28, 2009
    Posts:
    9
    I'm looking for a way to read pixel values from the resulting sprite sheet from within an EditorWindow. I'm writing a tool to that exposes the colors used in the sprites created from the PCB at editor time so that you can specify what colors to replace them at runtime. The tool then writes a texture that is used with a custom shader at runtime to do a palette swap.

    I can access the Texture2D via AssetDatabase.LoadAssetAtPath<Texture2D> but it isn't write enabled. I tried to modify its TextureImporter via AssetImporter.GetAtPath but that returns null.

    Update: I am a fool and now see there is an advanced setting on the importer to make the texture read/write enabled. Sorry!
     
    Last edited: Jun 23, 2022
    Ted_Wikman likes this.
  12. AmeX

    AmeX

    Joined:
    Mar 27, 2014
    Posts:
    14
  13. NunoEM

    NunoEM

    Joined:
    Nov 4, 2021
    Posts:
    1
    Hi! Would it be possible to:
    • be able to tick which layers you want and which you don't (our art team uses smart objects but those get translated to several duplicate sprites when imported through the tool)
      • I realized that this may be possible on higher versions (7+) but I'm bound to 2021 for now so having this ability there would be nice
    • OR allowing us to remove sprites from the auto-generated sprite sheet
    • (Even better) support smart objects being always translated to the same sprite
    • Allow us control to hijack the process of process the psb file and choosing if we want a sprite renderer hierarchy or a uGUI one (using spriteRenderers OR using ImgComponent with the sprite properly set and the layout still being recreated) <- this would be the best feature for next releases imho
    Cheers and keep up the good work!
     
    Leo-Yaik and EvOne like this.
  14. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    925
    Great suggestions, @NunoEM
    I've added them to our list of feedback items so that we can take it into consideration for future PSD Importer improvements.
     
  15. temurleng1

    temurleng1

    Joined:
    Jun 28, 2018
    Posts:
    17
    For anyone who interesting, You can change the psb file settings like below;


    Code (CSharp):
    1.        PSDImporter textureImporter = PSDImporter.GetAtPath("Assets/Images/player/player.psb") as PSDImporter;
    2.  
    3.         if (textureImporter != null)
    4.         {
    5.             TextureImporterPlatformSettings tip = new TextureImporterPlatformSettings();
    6.             tip.maxTextureSize = 512;
    7.             textureImporter.SetImporterPlatformSettings(tip);
    8.             textureImporter.SaveAndReimport();
    9.         }
     
    Last edited: Jan 28, 2023
    thehen2, Eristen and Ted_Wikman like this.