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
Install latest Unity 2019.3
Open Package Manager by going to Window > Package Manager
Choose 2D PSD Importer from the list and click on Install at the bottom right of the Package Manager window.
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.
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
if (toggle) {
var temp = new GameObject();
temp.name = "temp";
ctx.AddObjectToAsset("temp", temp);
}
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.
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.
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.
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!
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.
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?
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:
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.
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.
change the default Max Texture Size for new assets, or
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)
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.
@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?
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.
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.
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):