Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [4.0.1] - 2020-07-07
### Fixed
- Fixed ArgumentException thrown when 2D Game Kit is imported for the first time (case 1244287)
- Updated to use non-experimental AssetImporter  (case 1254380)
  • Loading branch information
Unity Technologies committed Jul 7, 2020
1 parent dc75498 commit 762a82e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [4.0.1] - 2020-07-07
### Fixed
- Fixed ArgumentException thrown when 2D Game Kit is imported for the first time (case 1244287)
- Updated to use non-experimental AssetImporter (case 1254380)

## [4.0.0] - 2020-05-11
### Changed
- Version bump for Unity 2020.2
Expand Down
23 changes: 18 additions & 5 deletions Editor/PSDImportPostProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ void OnPostprocessSprites(Texture2D texture, Sprite[] sprites)
{
var dataProviderFactories = new SpriteDataProviderFactories();
dataProviderFactories.Init();
ISpriteEditorDataProvider importer = dataProviderFactories.GetSpriteEditorDataProviderFromObject(AssetImporter.GetAtPath(assetPath));
PSDImporter psd = AssetImporter.GetAtPath(assetPath) as PSDImporter;
if (psd == null)
return;
ISpriteEditorDataProvider importer = dataProviderFactories.GetSpriteEditorDataProviderFromObject(psd);
if (importer != null)
{
importer.InitSpriteEditorDataProvider();
Expand All @@ -32,13 +35,23 @@ void OnPostprocessSprites(Texture2D texture, Sprite[] sprites)
var outlineOffset = sprite.rect.size / 2;
if (outline != null && outline.Count > 0)
{
var convertedOutline = new Vector2[outline.Count][];
// Ensure that outlines are all valid.
int validOutlineCount = 0;
for (int i = 0; i < outline.Count; ++i)
validOutlineCount = validOutlineCount + ( (outline[i].Length > 2) ? 1 : 0 );

int index = 0;
var convertedOutline = new Vector2[validOutlineCount][];
for (int i = 0; i < outline.Count; ++i)
{
convertedOutline[i] = new Vector2[outline[i].Length];
for (int j = 0; j < outline[i].Length; ++j)
if (outline[i].Length > 2)
{
convertedOutline[i][j] = outline[i][j] * definitionScale + outlineOffset;
convertedOutline[index] = new Vector2[outline[i].Length];
for (int j = 0; j < outline[i].Length; ++j)
{
convertedOutline[index][j] = outline[i][j] * definitionScale + outlineOffset;
}
index++;
}
}
sprite.OverridePhysicsShape(convertedOutline);
Expand Down
10 changes: 5 additions & 5 deletions Editor/PSDImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
using UnityEngine;
using Unity.Collections;
using System.Linq;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.AssetImporters;
using UnityEditor.U2D.Animation;
using UnityEditor.U2D.Common;
using UnityEditor.U2D.Sprites;
using UnityEngine.Assertions;
using UnityEngine.Experimental.U2D.Animation;
using UnityEngine.U2D;
using UnityEngine.U2D.Animation;
using UnityEditor.MemoryProfiler;
using UnityEngine.Profiling.Memory.Experimental;
using UnityEngine.Scripting.APIUpdating;

namespace UnityEditor.U2D.PSD
{
/// <summary>
/// ScriptedImporter to import Photoshop files
/// </summary>
[ScriptedImporter(4, "psb")]
[HelpURL("https://docs.unity3d.com/Packages/[email protected]/manual/index.html")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.psdimporter@latest")]
[MovedFrom("UnityEditor.Experimental.AssetImporters")]
public class PSDImporter : ScriptedImporter, ISpriteEditorDataProvider
{
class UniqueNameGenerator
Expand Down Expand Up @@ -342,7 +342,7 @@ TextureGenerationOutput ImportTexture(AssetImportContext ctx, NativeArray<Color3
var textureSpriteSettings = m_TextureImporterSettings.ExtractTextureSpriteSettings();
textureSpriteSettings.packingTag = m_SpritePackingTag;
textureSpriteSettings.qualifyForPacking = !string.IsNullOrEmpty(m_SpritePackingTag);
textureSpriteSettings.spriteSheetData = new UnityEditor.Experimental.AssetImporters.SpriteImportData[spriteCount];
textureSpriteSettings.spriteSheetData = new UnityEditor.AssetImporters.SpriteImportData[spriteCount];
textureSettings.npotScale = TextureImporterNPOTScale.None;
textureSettings.secondaryTextures = secondaryTextures;
var spriteImportData = GetSpriteImportData();
Expand Down
4 changes: 3 additions & 1 deletion Editor/PSDImporterEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
using System.Collections.Generic;
using System.IO;
using PhotoshopFile;
using UnityEditor.Experimental.AssetImporters;
using UnityEditor.AssetImporters;
using UnityEditor.U2D.Animation;
using UnityEditor.U2D.Common;
using UnityEditor.U2D.Sprites;
using UnityEngine;
using UnityEngine.Scripting.APIUpdating;

namespace UnityEditor.U2D.PSD
{
/// <summary>
/// Inspector for PSDImporter
/// </summary>
[CustomEditor(typeof(PSDImporter))]
[MovedFrom("UnityEditor.Experimental.AssetImporters")]
public class PSDImporterEditor : ScriptedImporterEditor, ITexturePlatformSettingsDataProvider
{
SerializedProperty m_TextureType;
Expand Down
4 changes: 2 additions & 2 deletions Editor/SpriteData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public static Vector2 GetPivotValue(SpriteAlignment alignment, Vector2 customOff
return Vector2.zero;
}

public static implicit operator UnityEditor.Experimental.AssetImporters.SpriteImportData(SpriteMetaData value)
public static implicit operator UnityEditor.AssetImporters.SpriteImportData(SpriteMetaData value)
{
var output = new UnityEditor.Experimental.AssetImporters.SpriteImportData();
var output = new UnityEditor.AssetImporters.SpriteImportData();
output.name = value.name;
output.alignment = value.alignment;
output.rect = value.rect;
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "com.unity.2d.psdimporter",
"version": "4.0.0",
"version": "4.0.1",
"unity": "2020.2",
"unityRelease": "0a14",
"unityRelease": "0a19",
"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.",
"keywords": [
Expand All @@ -12,19 +12,19 @@
],
"category": "2D",
"dependencies": {
"com.unity.2d.common": "4.0.0",
"com.unity.2d.animation": "5.0.0",
"com.unity.2d.common": "4.0.1",
"com.unity.2d.animation": "5.0.1",
"com.unity.2d.sprite": "1.0.0"
},
"relatedPackages": {
"com.unity.2d.psdimporter.tests": "4.0.0"
"com.unity.2d.psdimporter.tests": "4.0.1"
},
"upmCi": {
"footprint": "d2b08e5f1725cfeb59cd2f03f5c922d7f5579ed5"
"footprint": "8f06a9aae8646933a40d67cc3ac738f21194b732"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/2d.git",
"type": "git",
"revision": "4651ccecac488987a6b5bbb033282cb61de0e007"
"revision": "7d7470f4ca0ea8353d4c9640b3b6ae9d1ebd9c1d"
}
}

0 comments on commit 762a82e

Please sign in to comment.