Search Unity

Official 2D PSD Importer 6.0 released for Unity 2021.2

Discussion in '2D' started by rustum, Oct 25, 2021.

  1. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    2D PSD Importer 6.0 released for Unity 2021.2

    2D PSD Importer.png

    We’re happy to share that we’ve released 2D PSD Importer 6.0 for Unity 2021.2. This release is focused on layer management and mapping to improve the workflows from Photoshop and other image-editing tools into Unity.

    What’s new?
    • Added the ability to map SpriteRects to the layer name in a Photoshop file instead of using layer ids. More on this below.
    • Provided an automatic custom Physics shape generation option in the importer.
    • Added support to collapse the layers in a Photoshop file's Layer Group. This enables a workflow where multiple layers of art in Photoshop can generate a single Sprite in Unity. It’s no longer necessary to merge the layers in Photoshop.
    • Added the ability to configure Mosaic Padding to give users control over the space between each generated Sprite in a Texture.
    • Improved PSDImporter Inspector usability.
    More about layer names vs. layer ID
    The PSDImporter uses an ID that is stored internally by Photoshop for each layer to identify the mapping of the layer to the Sprite that was generated. Many third-party software that produce Photoshop Image files do not store the ID value resulting in potential data loss. In PSDImporter 6.0, users can have the option of using a Layer’s name to map to the Sprite it generates.

    See the full 2D PSD Importer 6.0 changelog here.

    About 2D PSD Importer
    The 2D PSD Importer is an Asset importer that imports Adobe Photoshop .psb files into Unity, and generates a Prefab of Sprites based on the imported source file.
    Read more in the 2D PSD Importer documentation.

    Getting Started
    1. Install the latest Unity 2021.2
    2. Start a new project with the 2D or 2D URP Template
    You can confirm that the 2D PSD Importer 6.0 package is installed by opening Package Manager (Window > Package Manager) and selecting the Packages: In Project from the dropdown.
    In Project.png

    You should see a verified version of 2D PSD Importer in your project.
    2D PSD Importer Package.png

    What can you do?
    Try it out and let us know what you think of the additions and improvements. We want to know what works as expected, what doesn’t and what is missing.
     
    suntabu, Zerosum_Unity and EvOne like this.
  2. suntabu

    suntabu

    Joined:
    Dec 21, 2013
    Posts:
    77
    Nice tools.
    Do you have any plans to support SpriteSkin on UGUI?
     
  3. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Thanks @suntabu
    Are you looking for SpriteSkin support for the image component in UGUI? If so, no we currently do not have any plans for it.
    If we supported this combination, how would you make use of it?
     
  4. suntabu

    suntabu

    Joined:
    Dec 21, 2013
    Posts:
    77
    Yes, we are. We wanna reduce the usage of image resources.
    Imagine this, an NPC fighting in my scene, and a dialogue panel UI with animate NPC character would be more attractive.

    But for now, we need to use unity rig animation for scene characters and spine's SkeletonGraphic for UI, which means completely duplicated character image resources.

    Finally, I know we can use SpriteRenderer with UGUI, but it's not convenient and effective.
     
    Last edited: Dec 14, 2021
  5. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Thanks for the insight.
    Another approach you could consider is setting up a secondary camera and render it into a RenderTexture. This RenderTexture can then be assigned to a RawImage component in the UI to visualize what the secondary camera is seeing.
     
  6. suntabu

    suntabu

    Joined:
    Dec 21, 2013
    Posts:
    77
    Using RenderTexture as RawImage's main texture is inconvenient too.
    Our game designers want to make UI very vivid and attractive, many rigged animations are displayed in UI.
    So it's very hard for every animation game object to create a camera RenderTexture.

    The spine is a very popular and successful 2D animation tool and they provided SkeletonGraphic for this situation.
    Why they provide SkeletonGraphic is just because they know that many many of us need it and it's very useful.

    Please reconsider this request carefully.

    Thanks!
     
  7. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    I see, good to know that you have considered this option as well.
    We will take this feedback into account when planning improvements to the 2D toolset for future versions.
    Thank you!
     
    suntabu likes this.
  8. suntabu

    suntabu

    Joined:
    Dec 21, 2013
    Posts:
    77
    Thanks.

    Looking forward to your next improvements.
     
    Ted_Wikman likes this.
  9. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,696
    The PSD importer is a great addition to the 2D workflow together with the animation system and am using it for a while :)
    Though I wonder is it possible to use it at runtime as well?
    Thinking of modding support where I'd like to keep the .psb file of the characters in the resource folder and load them at runtime.

    The triangulation and bone weights etc. would then be copied over from a dummy sprite set which has been designed inside the editor. This copying mechanism works now for psb files that have been imported in the editor, but they all have to exist at compiletime currently.
    Such a runtime feature would also be helpful to allow "baking" a character at runtime. For example to provide an advanced character editor where the player can add decorations ton the character that are then animated by the regular bones of the original psb file.

    Would you say that the PSD importer supports such a workflow?
     
  10. REDIZIT

    REDIZIT

    Joined:
    Apr 9, 2017
    Posts:
    1
    Hello, I have a bug with psd importer.
    Sorry, maybe I'm writing to the wrong thread, but I need your help.

    I use Unity 2022.1.0b2.2474 and package Version 7.0.0-pre.3 - October 25, 2021, I have problem with layer merging.
    I have psb character to rig. I want to import head as a folder in photoshop and merge it later in unity.
    So, I clicked merge and all is okay, until I noticed that layers merged with semi-transparent outline.
    I clicked some import options like filter mode, aniso level and etc, but no results.
    One way I found - merge folder into one layer before import to unity, as I did before upgraded and Layer Management tab added.

    I would be grateful for your help.

    upload_2021-12-31_16-29-4.png
    upload_2021-12-31_16-31-53.png upload_2021-12-31_16-33-14.png
     
  11. Kevin_OBrien

    Kevin_OBrien

    Joined:
    Feb 18, 2015
    Posts:
    14
    Getting a bug that makes the PSD file unreadable to unity whenever the file reimports.
    Skeletal data still remains but the sprites are not generated.

     
  12. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
  13. Kevin_OBrien

    Kevin_OBrien

    Joined:
    Feb 18, 2015
    Posts:
    14
    Have just done so, is case 1399529.
     
    Ted_Wikman likes this.
  14. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Thanks! Would you able to share your Photoshop file for us to take a look?
     
  15. Upp000

    Upp000

    Joined:
    Mar 4, 2021
    Posts:
    96
    Can unity psb importer leaves more space for each sprite?
    When unity imports a psb file, it generate a sprite for each layer, but the problem is, it leaves zero free space for them, it squeezes each sprites into a frame that fit perfectly, this might be good for saving ram, but if I draw more stuff in that layer, it will be cut out, and I will need to redo the rig! And the auto geometry in skinning editor is not working properly because of this, some part of the sprite is not included! I have no idea why unity didn't notice this, or is it because there is something that I don't know?
     
    EvOne likes this.
  16. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Thanks for the feedback @Uppet000!
    This is something the users can customise in the next version of PSD Importer (Unity 2022.2).

    For the second part of your comment, I would love to see this failure in action. Could you share some repro project with us?
     
  17. Upp000

    Upp000

    Joined:
    Mar 4, 2021
    Posts:
    96
    the seco
    the second half of my comment, it probably only happens when the resolution is very low, like pixel art
     
  18. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    Thanks for the insight! If it happens again, do file a bug report so we can take a closer look.
     
  19. Upp000

    Upp000

    Joined:
    Mar 4, 2021
    Posts:
    96
    currently, i fix all the problems I mentioned by drawing pixels on the edge of each layer, so that the whole layer would be included
     
    Ted_Wikman likes this.
  20. AmeX

    AmeX

    Joined:
    Mar 27, 2014
    Posts:
    14
    Hello, my unity version is 2021LTC
    When I tried to extend PSDImporter with these codes,

    Code (CSharp):
    1. namespace UnityEditor.U2D.PSD {
    2.     [ScriptedImporter( 2, new string[0], new[] { psdExt } )]
    3.     internal class PSDImporterOverride : PSDImporter {
    4.         public const string psdExt = "psd";
    5.         //public override void OnImportAsset( AssetImportContext ctx ) {
    6.         //    base.OnImportAsset( ctx );
    7.         //    DebugP.LogInfo( $"MyPSDImporter: {ctx.assetPath}" );
    8.         //}
    9.         [MenuItem( "Assets/Change PSD Importer", false, 30 )]
    10.         static void ChangeImporter() {
    11.             foreach ( var obj in Selection.objects ) {
    12.                 var path = AssetDatabase.GetAssetPath( obj );
    13.                 var ext = System.IO.Path.GetExtension( path ).Remove( "." );
    14.                 if ( ext != psdExt ) return;
    15.  
    16.                 var Importer = GetAtPath( path );
    17.                 if ( Importer == null || Importer is PSDImporterOverride ) {
    18.                     Debug.Log( $"imported with TextureImporter @ {path}" );
    19.                     AssetDatabase.ClearImporterOverride( path );
    20.                 }
    21.                 else {
    22.                     Debug.Log( $" imported with PSDImporter @ {path}" );
    23.                     AssetDatabase.SetImporterOverride<PSDImporterOverride>( path );
    24.                 }
    25.  
    26.             }
    27.         }
    28.     }
    29.     [CustomEditor( typeof( PSDImporterOverride ) )]
    30.     internal class PSDImporterOverrideEditor : PSDImporterEditor {
    31.     }
    32. }
    it throw out an error when I select or deselect any psd file:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.PropertyHandler.IsArrayReorderable (UnityEditor.SerializedProperty property) (at <780782bc035845f9909cebbd4c983ae3>:0)
    3. UnityEditor.PropertyHandler.UseReorderabelListControl (UnityEditor.SerializedProperty property) (at <780782bc035845f9909cebbd4c983ae3>:0)
    4. UnityEditor.GenericInspector.GetOptimizedGUIBlock (System.Boolean isDirty, System.Boolean isVisible, System.Single& height) (at <780782bc035845f9909cebbd4c983ae3>:0)
    5. UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <3d6ac16e3c754a199373804b462a1b72>:0)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
    7.  
    what's wrong and what referece is null?
     
  21. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    @AmeX what are you trying to do with this code?
     
  22. AmeX

    AmeX

    Joined:
    Mar 27, 2014
    Posts:
    14
    I'm trying to make my own importer for some reason
    and a importer changing tool could do some help when the new importer goes error
    now I know the problem is I did not name the c# file as same as the importer class (you did not mention this in here and the parameter of ScriptedImporterAttr is obsoleted:()
     
  23. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    916
    It sounds like you managed to resolve your issue, so thats great.
    Take note that the documentation page you are linking is for PSD Importer 8.0.0, which created for Unity 2022.2. PSD Importer 6.0.0 is the correct version for Unity 2021.3, and here is its documentation page.
     
  24. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190