-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [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
Showing
40 changed files
with
1,523 additions
and
1,339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} | ||
} | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.