Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [5.0.3] - 2021-03-28
### Fixed
- Fixed package description
- Fixed Unity hang when importing certain PSD files (case 1325770)

## [5.0.2] - 2021-03-21
### Changed
- Updated package dependencies

### Fixed
- Fixed manual documentation
  • Loading branch information
Unity Technologies committed Mar 28, 2021
1 parent a05cc07 commit 293e2c1
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## [5.0.3] - 2021-03-28
### Fixed
- Fixed package description
- Fixed Unity hang when importing certain PSD files (case 1325770)


## [5.0.2] - 2021-03-21
### Changed
- Updated package dependencies

### Fixed
- Fixed manual documentation

## [5.0.1] - 2021-03-19
### Changed
- Updated package dependencies
Expand Down
3 changes: 0 additions & 3 deletions Documentation~/PSD-override.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ From Unity 2019.30f1 onwards, the PSD Importer can be customized to import files

## PSDImporterOverride.cs
```
using System.IO;
using UnityEditor.Experimental;
using UnityEditor.Experimental.AssetImporters;
using UnityEngine;
namespace UnityEditor.U2D.PSD
Expand Down
2 changes: 1 addition & 1 deletion Documentation~/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Importing .psb files with the PSD Importer allows you to use features such as [M

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). Other Texture Modes may be supported in the future.

**Note:** The **Sprite Library Asset** swapping feature has been removed from the [2D Animation](https://docs.unity3d.com/Packages/com.unity.2d.animation@latest) package from version 6.0 onwards. However, the PSD Importer will continue to generate Sprite Library Assets if relevant data from a previous version is present.
**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.

## Supported and unsupported Photoshop effects

Expand Down
4 changes: 2 additions & 2 deletions Documentation~/skeleton-sharing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ When importing an Asset without anything set in the **Main Skeleton** property,

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

To share the 'Primary Skeleton' with the 'Variant' actor, 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.
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/[email protected]/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, you cannot edit the bones of the .skeleton when you open the current actor in the Skinning Editor (the Bone tools will be grayed out and unavailable). To edit the bones, you will need to edit the original actor (which the .skeleton Asset belongs to) in the Skinning Editor. Any changes to the .skeleton Asset is reflected in the bone hierarchy of any actor which references it. In our 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/[email protected]/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 .
26 changes: 18 additions & 8 deletions Editor/PSDImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using UnityEngine;
using Unity.Collections;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using UnityEditor.AssetImporters;
using UnityEditor.U2D.Animation;
using UnityEditor.U2D.Common;
Expand Down Expand Up @@ -545,7 +547,7 @@ void ImportFromLayers(AssetImportContext ctx, Document doc)
{
var psdLayer = psdLayers.FirstOrDefault(x => x.spriteID == spriteData.spriteID);
if (psdLayer == null)
spriteNameHash.Add(spriteData.name.GetHashCode());
spriteNameHash.Add(GetStringHash(spriteData.name));
}

foreach (var spriteData in spriteImportData)
Expand All @@ -556,7 +558,7 @@ void ImportFromLayers(AssetImportContext ctx, Document doc)
// If it is user created rect or the name has been changed before
// add it into the spriteNameHash and we don't copy it over from the layer
if (psdLayer == null || psdLayer.spriteName != spriteData.name)
spriteNameHash.Add(spriteData.name.GetHashCode());
spriteNameHash.Add(GetStringHash(spriteData.name));

// If the sprite name has not been changed, we ensure the new
// layer name is still unique and use it as the sprite name
Expand Down Expand Up @@ -1115,6 +1117,7 @@ bool CleanUpGameobjectsWithOutRig(GameObject root)

static string SanitizeName(string name)
{
name = name.Replace('\0', ' ');
string newName = null;
// We can't create asset name with these name.
if ((name.Length == 2 && name[0] == '.' && name[1] == '.')
Expand All @@ -1130,22 +1133,29 @@ static string SanitizeName(string name)
return name;
}

static int GetStringHash(string str)
{
MD5 md5Hasher = MD5.Create();
var hashed = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(str));
return BitConverter.ToInt32(hashed, 0);
}

static string GetUniqueName(string name, List<int> stringHash, bool logNewNameGenerated = false, UnityEngine.Object context = null)
{
string uniqueName = string.Copy(SanitizeName(name));
var sanitizedName = string.Copy(SanitizeName(name));
string uniqueName = sanitizedName;
int index = 1;
while (true)
{
int hash = uniqueName.GetHashCode();
var p = stringHash.Where(x => x == hash);
if (!p.Any())
var hash = GetStringHash(uniqueName);
if (!stringHash.Contains(hash))
{
stringHash.Add(hash);
if (logNewNameGenerated && name != uniqueName)
if (logNewNameGenerated && sanitizedName != uniqueName)
Debug.Log(string.Format("Asset name {0} is changed to {1} to ensure uniqueness", name, uniqueName), context);
return uniqueName;
}
uniqueName = string.Format("{0}_{1}", name, index);
uniqueName = string.Format("{0}_{1}", sanitizedName, index);
++index;
}
}
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "com.unity.2d.psdimporter",
"version": "5.0.1",
"version": "5.0.3",
"unity": "2021.1",
"displayName": "2D PSD Importer",
"description": "A ScriptedImporter for importing Adobe Photoshop PSB (Photoshop Big) file format. The ScriptedImporter is currently targeted for users who wants to create multi Sprite character animation using Unity 2D Animation Package.\n\nDocumentation for v5.0 is currently being updated.",
"description": "A ScriptedImporter for importing Adobe Photoshop PSB (Photoshop Big) file format. The ScriptedImporter is currently targeted for users who wants to create multi Sprite character animation using Unity 2D Animation Package.",
"keywords": [
"2d",
"psdimporter",
Expand All @@ -12,18 +12,18 @@
"category": "2D",
"dependencies": {
"com.unity.2d.common": "5.0.0",
"com.unity.2d.animation": "6.0.1",
"com.unity.2d.animation": "6.0.3",
"com.unity.2d.sprite": "1.0.0"
},
"relatedPackages": {
"com.unity.2d.psdimporter.tests": "5.0.1"
"com.unity.2d.psdimporter.tests": "5.0.3"
},
"upmCi": {
"footprint": "ea1429bf4ae47afb9cfb1359c557b9c825a670bc"
"footprint": "5aba28318664e28475f9e448bb3d02a1eed2fca5"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/2d.git",
"type": "git",
"revision": "1de540a091021db4de462f30f9a458120ea465ae"
"revision": "8752f08cdd2aa2a0153c9c70e2affdb28ccfe4bd"
}
}

0 comments on commit 293e2c1

Please sign in to comment.