Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [9.0.0-pre.1] - 2022-09-21
### Changed
- Simplified the Sprite Meta Data storage. We now have 3 storages; Single Sprite, Multiple Sprites and Mosaiac (Atlased) Sprites.
- Simplified the Psd Layer storage. We now only have one storage, Psd Layers.
- PSD Importer no longer depends on 2D Animation.

### Fixed
- Improved import speed and memory allocation for psd/psb files by reducing the intermediate texture buffers.
- Fixed exception when showing PSDImporter inspector. (Case DANB-195)
- Fixed a case where a .psd/.psb would not import with the correct layer coordinates.
  • Loading branch information
Unity Technologies committed Sep 21, 2022
1 parent e32d4cb commit 0ff59b2
Show file tree
Hide file tree
Showing 40 changed files with 1,523 additions and 1,339 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Changelog

## [8.0.0] - 2022-08-03
## [9.0.0-pre.1] - 2022-09-21
### Changed
- Package release version.
- Simplified the Sprite Meta Data storage. We now have 3 storages; Single Sprite, Multiple Sprites and Mosaiac (Atlased) Sprites.
- Simplified the Psd Layer storage. We now only have one storage, Psd Layers.
- PSD Importer no longer depends on 2D Animation.

### Fixed
- Fixed exception when showing PSDImporter inspector. (DANB-196)
- Improved import speed and memory allocation for psd/psb files by reducing the intermediate texture buffers.
- Fixed exception when showing PSDImporter inspector. (Case DANB-195)
- Fixed a case where a .psd/.psb would not import with the correct layer coordinates.

## [8.0.0-pre.3] - 2022-05-31
### Changed
Expand Down
4 changes: 1 addition & 3 deletions Documentation~/PSD-importer-SpriteRect.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# How the PSD Importer uses SpriteRect data
The PSD Importer can store five separate sets of[ SpriteRect](https://docs.unity3d.com/Packages/[email protected]/api/UnityEditor.SpriteRect.html) data, with one set for each of the five combinations of Importer property settings below:
The PSD Importer can store three separate sets of[ SpriteRect](https://docs.unity3d.com/Packages/[email protected]/api/UnityEditor.SpriteRect.html) data, with one set for each of the three combinations of Importer property settings below:
1. When [Sprite Mode](PSD-importer-properties.html#SpriteMode) is set to **Single**.
2. When **Sprite Mode** is set to **Multiple**.
3. When **Sprite Mode** is set to **Multiple,** and [Individual Sprites (Mosaic)](PSD-importer-properties.html#Mosaic) is enabled.
4. When **Sprite Mode** is set to **Multiple**, both **Individual Sprites (Mosaic)** and [Use as Rig](PSD-importer-properties.html#use-as-rig) are enabled, and there is no [Skeleton Asset](PSD-importer-properties.html#main-skeleton) assigned as the [Main Skeleton](PSD-importer-properties.html#main-skeleton).
5. When **Sprite Mode** is set to **Multiple**, both **Individual Sprites (Mosaic)** and **Use as Rig** are enabled, and a Skeleton Asset is assigned as the **Main Skeleton**.

Each set of data is persistent, and does not affect or overwrite the data of other sets. This means you can save different SpriteRect data for different importer settings for the same source file. The SpriteRect data persists even if you modify the dimensions and position of images in the source file, as long as the original [Layer ID](https://github.com/adobe-photoshop/generator-core/wiki/Understanding-Layer-IDs-and-Layer-Indices) of the source layers remains the same.

Expand Down
67 changes: 29 additions & 38 deletions Documentation~/PSD-override.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,45 @@
# PSD File Importer Override

From Unity 2019.30f1 onwards, you can customize the PSD Importer to import files with the .psd extension. To do that you need to create custom scripts that call the `AssetDatabaseExperimental.SetImporterOverride` method.
By default .psd files are imported with the Texture Importer. If you wish to instead import a .psd file with the PSD Importer, simply select the .psd file, click on the Importer dropdown and select **UnityEditor.U2D.PSD.PSDImporter**.

## Example SetImporterOverride scripts
### PSDImporterOverride.cs
![](images/psd-file-import.png)<br/>Importer drop down.

You can also create a script to automate this process. Below is an example of how this can be done using the `AssetDatabase.SetImporterOverride` method.

## Example SetImporterOverride script
### ChangePsdImporterUtility.cs
```
using UnityEditor;
using UnityEditor.U2D.PSD;
using UnityEngine;
namespace UnityEditor.U2D.PSD
public static class ChangePsdImporterUtility
{
[ScriptedImporter(1, "psd", AutoSelect = false)]
internal class PSDImporterOverride : PSDImporter
/// <summary>
/// Change importer of the currently selected .psd files.
/// </summary>
[MenuItem("Assets/2D Importer/Change PSD File Importer", false, 30)]
static void ChangeImporter()
{
[MenuItem("Assets/2D Importer", false, 30)]
[MenuItem("Assets/2D Importer/Change PSD File Importer", false, 30)]
static void ChangeImporter()
foreach (var obj in Selection.objects)
{
foreach (var obj in Selection.objects)
var path = AssetDatabase.GetAssetPath(obj);
var ext = System.IO.Path.GetExtension(path);
if (ext == ".psd")
{
var path = AssetDatabase.GetAssetPath(obj);
var ext = System.IO.Path.GetExtension(path);
if (ext == ".psd")
var importer = AssetImporter.GetAtPath(path);
if (importer is PSDImporter)
{
var importer = AssetImporter.GetAtPath(path);
if (importer is PSDImporterOverride)
{
Debug.Log(string.Format("{0} is now imported with TextureImporter", path));
AssetDatabaseExperimental.ClearImporterOverride(path);
}
else
{
Debug.Log(string.Format("{0} is now imported with PSDImporter", path));
AssetDatabaseExperimental.SetImporterOverride<PSDImporterOverride>(path);
}
Debug.Log($"{path} is now imported with TextureImporter");
AssetDatabase.ClearImporterOverride(path);
}
else
{
Debug.Log($"{path} is now imported with PSDImporter");
AssetDatabase.SetImporterOverride<PSDImporter>(path);
}
}
}
}
}
```

### PSDImporterOverrideEditor.cs
```
namespace UnityEditor.U2D.PSD
{
[CustomEditor(typeof(UnityEditor.U2D.PSD.PSDImporterOverride))]
internal class PSDImporterOverrideEditor : PSDImporterEditor
{
}
}
```
```
3 changes: 2 additions & 1 deletion Documentation~/TableOfContents.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* [PSD Importer Overview](index)
* [Introduction to PSD Importer](index)
* [What's new](whats-new)
* [PSD Importer Inspector properties](PSD-importer-properties)
* [Skeleton sharing](skeleton-sharing)
* [How SpriteRect data is used](PSD-importer-SpriteRect)
Expand Down
Binary file modified Documentation~/images/primary-character.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation~/images/primary-skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation~/images/primary-variant-assets.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/psd-file-import.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation~/images/rigged-primary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation~/images/variant-character.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Documentation~/images/variant-skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 18 additions & 2 deletions Documentation~/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
# Overview
# Introduction to PSD Importer
The **PSD Importer** is an [Asset importer](https://docs.unity3d.com/ScriptReference/AssetImporter.html) that imports [Adobe Photoshop .psb](https://helpx.adobe.com/photoshop/using/file-formats.html#large_document_format_psb) files into Unity, and generates a [Prefab](https://docs.unity3d.com/Manual/Prefabs.html) of Sprites based on the imported source file. The .psb file format is functionally identical to the more common Adobe [.psd format](https://helpx.adobe.com/photoshop/using/file-formats.html#photoshop_format_psd), but supports much larger images than the .psd format (up to 300,000 pixels in any dimension). To convert existing artwork from .psd to .psb format, you can open them in Adobe Photoshop and then save them as .psb files.

Importing .psb files with the PSD Importer allows you to use features such as [Mosaic](PSD-importer-properties.md#Mosaic) (to automatically generate a Sprite sheet from the imported layers) and [Character Rig](PSD-importer-properties.md#Rig) (to reassemble the Sprites of a character as they are arranged in their source files).

The PSD Importer currently only supports two [Texture Modes](https://docs.unity3d.com/Manual/TextureTypes.html):[ Default](https://docs.unity3d.com/Manual/TextureTypes.html#Default) and[ Sprite](https://docs.unity3d.com/Manual/TextureTypes.html#Sprite).

**Note:** The **Sprite Library Asset** is no longer editable from the Skinning Editor of the [2D Animation](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) from version 6.0 onwards as the Category and Label options have been removed from the Sprite Visibility panel. However, the PSD Importer will continue to automatically generate Sprite Library Assets if relevant data from a previous version is present.
The different versions of the PSD Importer package are supported by the following versions of Unity respectively:

Package version | Unity Editor version
--|--
9.x.x | 2023.1
8.x.x | 2022.2
7.x.x | 2022.1
6.x.x | 2021.2 or 2021.3
5.x.x | 2020.2 or 2020.3

## Support for .psd files

By default .psd files are imported with the Texture Importer. If you wish to instead import a .psd file with the PSD Importer, simply select the .psd file, click on the Importer dropdown and select **UnityEditor.U2D.PSD.PSDImporter**.

![](images/psd-file-import.png)<br/>Importer drop down.

For information on how to automate the selection of an importer, see the [PSD File Importer Override](PSD-override.md) section.

## Supported and unsupported Photoshop effects

Expand Down
12 changes: 6 additions & 6 deletions Documentation~/skeleton-sharing.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Skeleton sharing
You can share [.skeleton Assets](PSD-importer-properties.md#main-skeleton) between different imported Assets by assigning the .skeleton Asset from one to the other's **Main Skeleton** property. This feature can be used together with the [2D Animation package](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) to edit the [bones](https://docs.unity3d.com/Packages/com.unity.2d.animation@6.0/manual/SkinEdToolsShortcuts.html#bone-tools) of the .skeleton Assets in the 2D Animation package's [Skinning Editor](https://docs.unity3d.com/Packages/com.unity.2d.animation@6.0/manual/SkinningEditor.html).
You can share [.skeleton Assets](PSD-importer-properties.md#main-skeleton) between different imported Assets by assigning the .skeleton Asset from one to the other's **Main Skeleton** property. This feature can be used together with the [2D Animation package](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) to edit the [bones](https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/manual/SkinEdToolsShortcuts.html#bone-tools) of the .skeleton Assets in the 2D Animation package's [Skinning Editor](https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/manual/SkinningEditor.html).

To demonstrate how to skeleton sharing, refer to the following example of two actors (characters or other Assets imported for animation with the 2D Animation package) that were imported into Unity with the PSD Importer called 'Primary' and 'Variant'. The goal is to share the .skeleton Asset of 'Primary' with 'Variant'.
To demonstrate how to use skeleton sharing, refer to the following example of two actors (characters or other Assets imported for animation with the 2D Animation package) that were imported into Unity with the PSD Importer called 'Primary' and 'Variant'. The goal is to share the .skeleton Asset of 'Primary' with 'Variant'.

![](images/primary-variant-assets.png)
![](images/primary-character.png) | ![](images/variant-character.png)
--|--
Primary | Variant

The [2D Animation package](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) is required to create and edit the bones of the .skeleton Assets of imported Assets. In this example, the bones of 'Primary' are created and rigged in 2D Animation's [Skinning Editor](https://docs.unity3d.com/Packages/com.unity.2d.animation@6.0/manual/SkinningEditor.html) (refer to the [2D Animation package](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) documentation for further information).
The [2D Animation package](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) is required to create and edit the bones of the .skeleton Assets of imported Assets. In this example, the bones of 'Primary' are created and rigged in 2D Animation's [Skinning Editor](https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/manual/SkinningEditor.html) (refer to the [2D Animation package](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) documentation for further information).

![](images/rigged-primary.png)<br/>A bone hierarchy connected together to form the skeleton of 'Primary'.

When importing an Asset without anything set in the **Main Skeleton** property, the PSD Importer generates a .skeleton Asset for the Asset and automatically names it as '[Asset File Name] Skeleton'. Any [bones rigged](https://docs.unity3d.com/Packages/com.unity.2d.animation@6.0/manual/SkinEdToolsShortcuts.html#bone-tools) for 'Primary' is saved to the .skeleton Asset 'Primary Skeleton'.
When importing an Asset without anything set in the **Main Skeleton** property, the PSD Importer generates a .skeleton Asset for the Asset and automatically names it as '[Asset File Name] Skeleton'. Any [bones rigged](https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/manual/SkinEdToolsShortcuts.html#bone-tools) for 'Primary' is saved to the .skeleton Asset 'Primary Skeleton'.

![](images/primary-skeleton.png)

To share the 'Primary Skeleton' with 'Variant', select 'Variant' and go to its PSD Importer settings. Assign 'Primary Skeleton' to the **Main Skeleton** property to have 'Variant' reference that .skeleton Asset as its own bone hierarchy.

![](images/variant-skeleton.png)<br/>The [Bone tools](https://docs.unity3d.com/Packages/com.unity.2d.animation@6.0/manual/SkinEdToolsShortcuts.html#bone-tools) are greyed out and unavailable when opening 'Variant' in the Skinning Editor.
![](images/variant-skeleton.png)<br/>The [Bone tools](https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/manual/SkinEdToolsShortcuts.html#bone-tools) are greyed out and unavailable when opening 'Variant' in the Skinning Editor.

When an actor references another actor's .skeleton Asset instead of its own, the [Bone Tools](https://docs.unity3d.com/Packages/com.unity.2d.animation@6.0/manual/SkinEdToolsShortcuts.html#bone-tools) in the Skinning Editor are disabled. To edit the bones, open the original actor (that the .skeleton Asset belongs to) in the Skinning Editor and edit the bones. Any changes to the original .skeleton Asset is reflected in any actor which references it. In this example, changes made to 'Primary Skeleton' are reflected in the 'Variant' actor's bone hierarchy .
When an actor references another actor's .skeleton Asset instead of its own, the [Bone Tools](https://docs.unity3d.com/Packages/com.unity.2d.animation@9.0/manual/SkinEdToolsShortcuts.html#bone-tools) in the Skinning Editor are disabled. To edit the bones, open the original actor (that the .skeleton Asset belongs to) in the Skinning Editor and edit the bones. Any changes to the original .skeleton Asset is reflected in any actor which references it. In this example, changes made to 'Primary Skeleton' are reflected in the 'Variant' actor's bone hierarchy .
8 changes: 8 additions & 0 deletions Documentation~/whats-new.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# What's new in version 9.0

## Improved
- Faster imports of .psd/.psb files. The update will be particularly noticable when importing files with many layers.
- Reduced the memory overhead when importing a .psd/.psb file.

## Updated
- Reduced the number of [Sprite Rect Data](PSD-importer-SpriteRect.md) containers, from five to three.
Loading

0 comments on commit 0ff59b2

Please sign in to comment.