2D PSDImporter 5.0 released for Unity 2021.1

2D PSDImporter 5.0 released for Unity 2021.1

What’s new?
With the release of Unity 2021.1 2D PSDImporter 5.0 is now available. This release includes:

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 the complete documentation here. Read more in the 2D PSD Importer documentation.

Getting Started
In an existing project in Unity 2021.1:

Creating a new project in Unity 2021.1 by selecting the 2D Template in Unity Hub will also install 2D PSDImporter 5.0 by default.

What can you do?
Try it out and let us know what you think of the package. We want to know what works as expected, what doesn’t and what is missing.

I had 5.0.1 already installed in my project and I got an update to 5.0.3. Upgrading the package also upgrades 2D Animation to 6.0.3.

On your image, the sprites are visible; in my project they are not, it’s been like that since several versions now.

I notice that the package and others require Mathematics 1.1.0 but I have 1.2.1 installed and I have no option to downgrade the package to 1.1.0.

I’m using the PSD file Importer Override scripts mentioned here so that I can import my psd files directly. They work, mostly, provided you add

using UnityEditor.AssetImporters;

to the PSDImporterOverride.cs and you set the class to “public” instead of “internal”. :slight_smile:

There is a small problem though; in

[ScriptedImporter(1, "psd", AutoSelect = false)]

AutoSelect is deprecated and supposed to be replaced by overrideFileExtensions. Unfortunately I don’t know how to do that and I’m not good enough to guess by myself, since the documentation is useless in the matter.

Help would be welcome! :slight_smile:

1 Like

Well, the documentation proved useful after all and I found a suitable replacement fot the deprecated code:

[ScriptedImporter(1, new[] { "psb" }, new[] { "psd" })]
3 Likes

We will update the sample code as soon as we can!

1 Like

The code works but I sometimes get the following error message on entering play mode. This message doesn’t prevent working on the project though. I guess something should be added to the override script to avoid this kind of confusion?

Multiple scripted importers are targeting the extension 'psb' and have all been rejected: UnityEditor.U2D.PSD.PSDImporter (assembly: /media/anne/SSDSamsungT1/Faire/Unity Technologies/Projets/Personnels/Unnamed Game (2D tools - 2021.2)/Library/ScriptAssemblies/Unity.2D.Psdimporter.Editor.dll), UnityEditor.U2D.PSD.PSDImporterOverride (assembly: /media/anne/SSDSamsungT1/Faire/Unity Technologies/Projets/Personnels/Unnamed Game (2D tools - 2021.2)/Library/ScriptAssemblies/Assembly-CSharp.dll)
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3  (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
#4  (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
#5 mono_print_method_from_ip
#6 mono_perfcounter_foreach
#7 mono_runtime_invoke
#8 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#9 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#10 ScriptedImporter::RegisterImporters()
#11 MonoManager::EndReloadAssembly(DomainReloadingData&, dynamic_bitset)
#12 MonoManager::ReloadAssembly()
#13 ReloadAllUsedAssemblies()
#14 EditorSceneManager::RestoreSceneBackups(std::vector<EditorSceneBackup, stl_allocator<EditorSceneBackup, (MemLabelIdentifier)123, 16> >&, EditorSceneManager::PlayModeChange)
#15 PlayerLoopController::EnterPlayMode()
#16 PlayerLoopController::SetIsPlaying(bool)
#17 Application::TickTimer()
#18 MainMessageIteration(void*)
#19 g_main_context_dispatch
#20 g_main_context_dispatch
#21 g_main_loop_run
#22 gtk_main
#23 main
#24 __libc_start_main
#25 _start

You can do it by removing the “psb” in the override
i.e.
ScriptedImporter(1, new[ ] { “” }, new[ ] { “psd” })

1 Like

Trying that…

and it’s working, the message has disappeared. Thanks! :slight_smile:

I don’t know if this is your area of expertise but each time I load my project I get this warning:

SceneView rotation is fixed to identity when in 2D mode. This will be an error in future versions of Unity.
#0 GetStacktrace(int)
#1 DebugStringToFile(DebugStringToFileData const&)
#2 DebugLogHandler_CUSTOM_Internal_Log(LogType, LogOption, ScriptingBackendNativeStringPtrOpaque*, ScriptingBackendNativeObjectPtrOpaque*)
#3  (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
#4  (Mono JIT Code) [SceneViewStageHandling.cs:128] UnityEditor.SceneViewStageHandling:LoadCameraState (UnityEditor.SceneView,UnityEditor.SceneManagement.Stage)
#5  (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
#6 mono_print_method_from_ip
#7 mono_perfcounter_foreach
#8 mono_runtime_invoke
#9 scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#10 ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#11 ScriptingInvocation::InvokeChecked(ScriptingExceptionPtr*)
#12 SerializableManagedRef::CallMethod(Object&, ScriptingMethodPtr)
#13 MonoBehaviour::AwakeFromLoad(AwakeFromLoadMode)
#14 AwakeFromLoadQueue::InvokePersistentManagerAwake(AwakeFromLoadQueue::Item*, unsigned int, AwakeFromLoadMode, bool)
#15 AwakeFromLoadQueue::PersistentManagerAwakeFromLoad()
#16 PersistentManager::IntegrateAllThreadedObjects()
#17 PersistentManager::LoadFileCompletely(core::basic_string_ref<char>)
#18 LoadSerializedFileAndForget(core::basic_string<char, core::StringStorageDefault<char> > const&, std::vector<Object*, std::allocator<Object*> >&)
#19 InternalEditorUtilityBindings::LoadSerializedFileAndForget(core::basic_string<char, core::StringStorageDefault<char> > const&)
#20 InternalEditorUtility_CUSTOM_LoadSerializedFileAndForget(ScriptingBackendNativeStringPtrOpaque*)
#21  (Mono JIT Code) (wrapper managed-to-native) UnityEditorInternal.InternalEditorUtility:LoadSerializedFileAndForget (string)
#22  (Mono JIT Code) [WindowLayout.cs:368] UnityEditor.WindowLayout:LoadProjectLayout (bool)

Should I worry?

I did that and it works as I already said but now the menu line for the default importer doesn’t appear in Assets, in 2021.2. The fix is easy:

        [MenuItem("Assets/2D Importer/Default", false, 30)]

instead of:

        [MenuItem("Assets/2D Importer", false, 30)]

does the trick.

The script looks now like this:

using UnityEngine;
using UnityEditor.AssetImporters;

namespace UnityEditor.U2D.PSD
{
    [ScriptedImporter(1, new[] { "" }, new[] { "psd" })]
    public class PSDImporterOverride : PSDImporter
    {
        [MenuItem("Assets/2D Importer/Default", false, 30)]
        [MenuItem("Assets/2D Importer/Change PSD File Importer", false, 30)]
        static void ChangeImporter()
        {
            foreach (var obj in Selection.objects)
            {
                var path = AssetDatabase.GetAssetPath(obj);
                var ext = System.IO.Path.GetExtension(path);
                if (ext == ".psd")
                {
                    var importer = AssetImporter.GetAtPath(path);
                    if (importer is PSDImporterOverride)
                    {
                        Debug.Log(string.Format("{0} is now imported with PSDImporterOverride", path));
                        AssetDatabase.ClearImporterOverride(path);
                    }
                    else
                    {
                        Debug.Log(string.Format("{0} is now imported with PSDImporter", path));
                        AssetDatabase.SetImporterOverride<PSDImporterOverride>(path);
                    }
                }
            }
        }
    }
}
1 Like

Not sure if it belongs here or in 2d-animation discussion, but current workflow with normal maps has an issue.
Sometimes, PSD importer has quantum-tier differences in arrangement of sprites in atlas for seemingly identical PSB files. Using such atlas with misplaced sprites as a normal map in secondary textures, naturally leads to wrong results after rendering is done.
PSD importer is changing the arrangement of sprites in atlas quite often actually, despite me locking transparency of layers when I edit the source.
This randomness is absolutely killing me. Can we have some control over how sprites are arranged in atlas? Currently, I’m dealing with it by directly exporting atlas texture and drawing a normal version over it. But as you would expect, this method is terrible since, again, PSD importer can change the arrangement of the base file at any moment because it reacted to space radiation, Moon phase, or something else.

2 Likes

The arrangement shouldn’t change unless there is a size change in any layer i.e. the visual of a layer has gone bigger or smaller. The size change sometimes can be undetecteable by the naked eye eg there might be residue of a pixel that has very low alpha value from previous paint and erase. We are considering adding a ‘alpha tolerance’ parameter during import so that it can be tweak to prevent this from happening.

1 Like

At the mean time, we are also relooking at a better workflow for having secondary texture

2 Likes

It looks like combining a few layers during edit caused edited sprites to get a combined alpha channel (despite locked layers) which is triggered rearrangement. After I restricted my workflow to using clipping masks only, I’ve managed to prevent my atlases from rearranging sprites. Still… limiting artists in their workflow is not a good thing.
I understand where the issue lies but I can’t suggest any elegant solution. Maybe… sharing atlas coordinates for sprites? Since we need a normal map to be exactly the same as the main file, it’s kind of logical for main file to share its arrangement if our layers named identically.

1 Like

Yes, we are thinking along that line as well for how it works under the hood. On top of that, we would also thinking of a UI/UX flow that makes sense and hassle free as much as possible.

1 Like

hello

Hey @berdanka , thank you for your helpful feedback! Yes, this is definitely something we would want to look into.

Hi folks! 2D PSD Importer 6.0 has been released for Unity 2021.2. :slight_smile: I’m unsticking this thread. Please join the discussion here .

6.0.1 with unity 2022.1.0a13. This is not working

Doing anything and the default importer is not changing. Reimport, copy new psd into project, delete meta file, any and everything cannot change default importer

7636141--950971--upload_2021-11-7_20-20-24.png

@Thaina you should now be able to upgrade to PSD Importer 7.0.0-pre.3, which is the latest package version for Unity 2022.1. Have a look at our documentation on how to create a PSD Override with PSD Importer 7.0.0-pre.3 and let us know how it goes.

1 Like

Are you expecting that it will be imported with the PSDImporterOverride by default?