From fbd0b6be9fc810b1125cb24d8e63d8cdec8a5499 Mon Sep 17 00:00:00 2001 From: Unity Technologies <@unity.com> Date: Fri, 25 Jan 2019 00:00:00 +0100 Subject: [PATCH] com.unity.2d.psdimporter@1.0.0-preview.2 ## [1.0.0-preview.2] - 2019-01-25 ### Added - Fix unable to rig Sprites created manually - Remove legacy packing tag - Default Texture Type is changed to 'Sprite (2D and UI)' - Default Sprite Mode is changed to 'Multiple' --- CHANGELOG.md | 7 ++ Documentation~/PSDImporter.md | 13 +- Editor/PSDImporter.cs | 35 +++--- Editor/PSDImporterEditor.cs | 5 +- Editor/PSDPlugin/PsdFile/Layers/Layer.cs | 2 +- Editor/PSDPlugin/PsdFile/Layers/LayerInfo.cs | 117 +++++++++++------- Editor/PSDPlugin/PsdFile/PsdFile.cs | 6 +- Editor/SpriteData.cs | 2 +- .../PSDImporterDataProviderTests.cs | 38 ++++++ Tests/EditorTests/PSDImporterTests.cs | 6 +- package.json | 4 +- 11 files changed, 153 insertions(+), 82 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fdd9ea..17a1bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.0.0-preview.2] - 2019-01-25 +### Added +- Fix unable to rig Sprites created manually +- Remove legacy packing tag +- Default Texture Type is changed to 'Sprite (2D and UI)' +- Default Sprite Mode is changed to 'Multiple' + ## [1.0.0-preview.1] - 2018-11-20 ### Added - New release diff --git a/Documentation~/PSDImporter.md b/Documentation~/PSDImporter.md index e2bcdd7..db913b1 100644 --- a/Documentation~/PSDImporter.md +++ b/Documentation~/PSDImporter.md @@ -28,7 +28,7 @@ The following Photoshop features are **not** supported by the PSD Importer **:** ### Texture Type - Default -This is the default **Texture Type** when an image is imported without a specific Texture Type selected. Refer to the documentation on [Texture Types](https://docs.unity3d.com/Manual/TextureTypes.html) for further information and details. +This is the default **Texture Type** usage when an image is imported without a specific Texture Type selected. Refer to the documentation on [Texture Types](https://docs.unity3d.com/Manual/TextureTypes.html) for further information and details. ### Texture Type - Sprite (2D and UI) @@ -41,10 +41,9 @@ Property settings that are specific to the **PSD Importer** are marked by an *. | Property | Function | | ------------------------------- | ------------------------------------------------------------ | | __Texture Type__ | Select __Sprite (2D and UI)__ to import the Texture as a [Sprite](https://docs.unity3d.com/Manual/Sprites.html). This is required to begin using the imported images with the 2D Animation V2 package. | -| __Sprite Mode__ | Use this setting to specify how the the Sprite graphic is extracted from the image. The default for this option is **Single**. | +| __Sprite Mode__ | Use this setting to specify how the the Sprite graphic is extracted from the image. The default for this option is **Multiple**. | | Single | Select this option if there is only a single element in the imported image. | | Multiple | Select this option if there are multiple elements in the imported image. Select this option when importing a character meant for animation with the 2D Animation V2 package. | -| __Packing Tag__ | Specify a __Sprite Atlas__ by name, where the Texture into using the legacy Sprite Packer packing tag. | | __Pixels Per Unit__ | The number of pixels that equal 1 Unity unit. | | __Mesh Type__ | This defines the __Mesh__ type that is generated for the __Sprite__. The default for this option is 'Tight'. | | Full Rect | The Sprite is mapped onto a mesh generated as a quad. | @@ -53,7 +52,7 @@ Property settings that are specific to the **PSD Importer** are marked by an *. | * [Import Hidden](#ImportHidde) | Select this property to specify that hidden layers in the PSB file should be imported. Clear this option to not import the hidden layers. | | * [Mosaic](#Mosaic) | This option is only available if Texture Type is set to ‘Multiple’. Enable this to allow Unity to create a Sprite from each imported layer and arrange them into a Sprite Sheet layout. | | * [Character Rig](#CharRig) | Select the imported image(s) is to be used for a multi-Sprite character. When selected, a Prefab containing the imported images is generated. | -| * [Use Folder Grouping](#Hierarchy) | Select to have the generated Prefab mimic the layer hierarchy of the imported PSB file. | +| * [Use Layer Grouping](#Hierarchy) | Select to have the generated Prefab mimic the layer hierarchy of the imported PSB file. | | __Pivot__ | Select the pivot point of the Sprite from the dropdown menu options. | | Custom | Define the X and Y coordinates of a custom __Pivot__ location. | | * [Reslice](#Reslice) | Available only when __Mosaic__ is enabled.
Select this to clear away all previous Sprite metadata and recreate the Sprite from the imported PSB layers. | @@ -70,7 +69,7 @@ The 4 sets are created by enabling the following property combinations: 3. Sprite Mode: Multiple + Mosaic -4. Sprite Mode: Multiple + Mosaic + Character Rig** +4. Sprite Mode: Multiple + Mosaic + Character Rig #### User defined SpriteRect @@ -113,7 +112,7 @@ When **Mosaic** is selected, all layers in the PSB file will be imported as sepa When this is selected, a Prefab is generated containing a Sprite GameObject with the SpriteRenderer component. If the Sprite contains bone and skin data, the **Sprite Skin** component is added as well. The name of the GameObject is the same as the name specified in it's SpriteRect. -### Use Folder Grouping +### Use Layer Grouping When this is selected, the generated GameObjects mimic the layer grouping in the imported file. When the Asset hierarchy is modified, it is reflected on the next import. @@ -125,7 +124,7 @@ When this is selected, all user modification is discarded and SpriteRects are re A name collision can occur in the following ways: -1. 2 or more layers in the Asset has the same name. This does not affect Photoshop folder name. +1. 2 or more layers in the Asset has the same name. This does not affect Photoshop group name. 2. A new layer created in the Asset has the same name as a user created SpriteRect. diff --git a/Editor/PSDImporter.cs b/Editor/PSDImporter.cs index 449adc3..8b54b96 100644 --- a/Editor/PSDImporter.cs +++ b/Editor/PSDImporter.cs @@ -85,9 +85,6 @@ public int textureActualHeight [SerializeField] BoneGO[] m_BoneGOs; - [SerializeField] - bool m_FirstCreate = true; - [SerializeField] bool m_GenerateGOHierarchy = false; @@ -150,12 +147,6 @@ public override void OnImportAsset(AssetImportContext ctx) if (ext != ".psb") throw new Exception("File does not have psb extension"); - if (m_FirstCreate) - { - m_TextureImporterSettings.textureType = EditorSettings.defaultBehaviorMode == EditorBehaviorMode.Mode2D ? TextureImporterType.Sprite : TextureImporterType.Default; - m_FirstCreate = false; - } - m_BoneGOs = null; FileStream fileStream = new FileStream(ctx.assetPath, FileMode.Open, FileAccess.Read); @@ -202,8 +193,8 @@ public override void OnImportAsset(AssetImportContext ctx) if (spriteImportData.Count <= 0 || spriteImportData[0] == null) { spriteImportData.Add(new SpriteMetaData()); - spriteImportData[0].name = System.IO.Path.GetFileNameWithoutExtension(ctx.assetPath); } + spriteImportData[0].name = System.IO.Path.GetFileNameWithoutExtension(ctx.assetPath) +"_1"; spriteImportData[0].alignment = (SpriteAlignment)m_TextureImporterSettings.spriteAlignment; spriteImportData[0].border = m_TextureImporterSettings.spriteBorder; spriteImportData[0].pivot = m_TextureImporterSettings.spritePivot; @@ -413,6 +404,8 @@ void ImportFromLayers(AssetImportContext ctx, Document doc) foreach (var spriteData in spriteImportData) { var psdLayer = psdLayers.FirstOrDefault(x => x.spriteID == spriteData.spriteID); + if (psdLayer == null) + spriteData.uvTransform = new Vector2Int((int)spriteData.rect.position.x, (int)spriteData.rect.position.y); // 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) @@ -503,6 +496,7 @@ public TextureImporterPlatformSettings GetPlatformTextureSettings(BuildTarget bu void RegisterAssets(AssetImportContext ctx, TextureGenerationOutput output) { + List assetNameHash = new List(); if (!string.IsNullOrEmpty(output.importInspectorWarnings)) { Debug.LogWarning(output.importInspectorWarnings); @@ -518,21 +512,28 @@ void RegisterAssets(AssetImportContext ctx, TextureGenerationOutput output) { throw new Exception("Texture import fail"); } - var assetName = System.IO.Path.GetFileNameWithoutExtension(ctx.assetPath); + var assetName = GetUniqueName(System.IO.Path.GetFileNameWithoutExtension(ctx.assetPath), assetNameHash, true); output.texture.name = assetName; ctx.AddObjectToAsset(assetName, output.texture, output.thumbNail); UnityEngine.Object mainAsset = output.texture; + + if (output.sprites != null) { foreach (var s in output.sprites) - ctx.AddObjectToAsset(s.name, s); + { + assetName = GetUniqueName(s.name, assetNameHash, true, s); + ctx.AddObjectToAsset(assetName, s); + } + if (shouldProduceGameObject) { var prefab = OnProducePrefab(assetName, output.sprites); if (prefab != null) { - ctx.AddObjectToAsset(prefab.name, prefab); + assetName = GetUniqueName(prefab.name, assetNameHash, true, prefab); + ctx.AddObjectToAsset(assetName, prefab); mainAsset = prefab; } } @@ -684,7 +685,7 @@ GameObject OnProducePrefab(string assetname, Sprite[] sprites) spriteRenderer.sortingOrder = psdLayers.Count - i; var uvTransform = spriteMetaData.uvTransform; var outlineOffset = new Vector2(spriteMetaData.rect.x - uvTransform.x + (spriteMetaData.pivot.x * spriteMetaData.rect.width), - spriteMetaData.rect.y - uvTransform.y + (spriteMetaData.pivot.y * spriteMetaData.rect.height)) * definitionScale / sprite.pixelsPerUnit; + spriteMetaData.rect.y - uvTransform.y + (spriteMetaData.pivot.y * spriteMetaData.rect.height)) * definitionScale / sprite.pixelsPerUnit; l.gameObject.transform.position = new Vector3(outlineOffset.x, outlineOffset.y, 0); if (characterSkeleton != null) @@ -803,7 +804,7 @@ static string SanitizeName(string name) return name; } - static string GetUniqueName(string name, List stringHash) + static string GetUniqueName(string name, List stringHash, bool logNewNameGenerated = false, UnityEngine.Object context = null) { string uniqueName = string.Copy(SanitizeName(name)); int index = 1; @@ -814,6 +815,8 @@ static string GetUniqueName(string name, List stringHash) if (!p.Any()) { stringHash.Add(hash); + if (logNewNameGenerated && name != 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); @@ -1047,7 +1050,7 @@ internal void PostProcessPrefab(GameObject go) var spriteSkin = go.GetComponent(); if (spriteSkin != null) { - var spriteBones = m_CharacterData.parts.FirstOrDefault(x => new GUID(x.spriteId) == sr.sprite.GetSpriteID()).bones.Select(x => m_BoneGOs[x]); + var spriteBones = m_CharacterData.parts.FirstOrDefault(x => new GUID(x.spriteId) == sr.sprite.GetSpriteID()).bones.Where(x => x >= 0 && x < m_BoneGOs.Length).Select(x => m_BoneGOs[x]); if (spriteBones.Any()) { spriteSkin.rootBone = spriteBones.OrderBy(x => x.index).First().go.transform; diff --git a/Editor/PSDImporterEditor.cs b/Editor/PSDImporterEditor.cs index b95375a..2907f04 100644 --- a/Editor/PSDImporterEditor.cs +++ b/Editor/PSDImporterEditor.cs @@ -15,7 +15,6 @@ public class PSDImporterEditor : ScriptedImporterEditor SerializedProperty m_TextureType; SerializedProperty m_TextureShape; SerializedProperty m_SpriteMode; - SerializedProperty m_SpritePackingTag; SerializedProperty m_SpritePixelsToUnits; SerializedProperty m_SpriteMeshType; SerializedProperty m_SpriteExtrude; @@ -61,7 +60,6 @@ public class PSDImporterEditor : ScriptedImporterEditor TexturePlatformSettingsController m_TexturePlatformSettingsController = new TexturePlatformSettingsController(); public override void OnEnable() { - m_SpritePackingTag = serializedObject.FindProperty("m_SpritePackingTag"); m_MosaicLayers = serializedObject.FindProperty("m_MosaicLayers"); m_ImportHiddenLayers = serializedObject.FindProperty("m_ImportHiddenLayers"); m_ResliceFromLayer = serializedObject.FindProperty("m_ResliceFromLayer"); @@ -567,7 +565,6 @@ void DoSpriteInspector() // Show generic attributes if (m_SpriteMode.intValue != 0) { - EditorGUILayout.PropertyField(m_SpritePackingTag, s_Styles.spritePackingTag); EditorGUILayout.PropertyField(m_SpritePixelsToUnits, s_Styles.spritePixelsPerUnit); if (m_SpriteMode.intValue != (int)SpriteImportMode.Polygon && !m_SpriteMode.hasMultipleDifferentValues) @@ -865,7 +862,7 @@ internal class Styles public readonly GUIContent applyButtonLabel = new GUIContent("Apply"); public readonly GUIContent revertButtonLabel = new GUIContent("Revert"); public readonly GUIContent spriteEditorButtonLabel = new GUIContent("Sprite Editor"); - public readonly GUIContent resliceFromLayerWarning = new GUIContent("This will reinitialized and recreate all Sprites based on the file's layer. Existing Sprite metadata for previous generated Sprite will be copied over."); + public readonly GUIContent resliceFromLayerWarning = new GUIContent("This will reinitialize and recreate all Sprites based on the file’s layer data. Existing Sprite metadata from previously generated Sprites are copied over."); public readonly GUIContent alphaIsTransparency = new GUIContent("Alpha Is Transparency", "If the provided alpha channel is transparency, enable this to pre-filter the color to avoid texture filtering artifacts. This is not supported for HDR textures."); public readonly GUIContent etc1Compression = new GUIContent("Compress using ETC1 (split alpha channel)|Alpha for this texture will be preserved by splitting the alpha channel to another texture, and both resulting textures will be compressed using ETC1."); public readonly GUIContent crunchedCompression = new GUIContent("Use Crunch Compression", "Texture is crunch-compressed to save space on disk when applicable."); diff --git a/Editor/PSDPlugin/PsdFile/Layers/Layer.cs b/Editor/PSDPlugin/PsdFile/Layers/Layer.cs index 11b0cf7..77dc40f 100644 --- a/Editor/PSDPlugin/PsdFile/Layers/Layer.cs +++ b/Editor/PSDPlugin/PsdFile/Layers/Layer.cs @@ -187,7 +187,7 @@ public Layer(PsdBinaryReader reader, PsdFile psdFile) { var layerInfo = LayerInfoFactory.Load(reader, psdFile: this.PsdFile, - globalLayerInfo: false); + globalLayerInfo: false, adjustmentLayerEndPos); AdditionalInfo.Add(layerInfo); } diff --git a/Editor/PSDPlugin/PsdFile/Layers/LayerInfo.cs b/Editor/PSDPlugin/PsdFile/Layers/LayerInfo.cs index 35a849a..89d5daf 100644 --- a/Editor/PSDPlugin/PsdFile/Layers/LayerInfo.cs +++ b/Editor/PSDPlugin/PsdFile/Layers/LayerInfo.cs @@ -28,7 +28,7 @@ public static class LayerInfoFactory /// loaded from the end of the Layer and Mask Information section; /// false if it is being loaded from the end of a Layer record. public static LayerInfo Load(PsdBinaryReader reader, PsdFile psdFile, - bool globalLayerInfo) + bool globalLayerInfo, long fileEndPos) { Util.DebugMessage(reader.BaseStream, "Load, Begin, LayerInfo"); @@ -43,53 +43,79 @@ public static LayerInfo Load(PsdBinaryReader reader, PsdFile psdFile, var key = reader.ReadAsciiChars(4); var hasLongLength = LayerInfoUtil.HasLongLength(key, psdFile.IsLargeDocument); - var length = hasLongLength - ? reader.ReadInt64() - : reader.ReadInt32(); - var startPosition = reader.BaseStream.Position; - - LayerInfo result; - switch (key) + LayerInfo result = new RawLayerInfo("dummy"); + bool breakFromLoop = false; + while (!breakFromLoop) { - case "Layr": - case "Lr16": - case "Lr32": - result = new InfoLayers(reader, psdFile, key, length); - break; - case "lsct": - case "lsdk": - result = new LayerSectionInfo(reader, key, (int)length); - break; - case "luni": - result = new LayerUnicodeName(reader); - break; - case "lyid": - result = new LayerId(reader, key, length); - break; - default: - result = new RawLayerInfo(reader, signature, key, length); - break; + var baseStartPosition = reader.BaseStream.Position; + var length = hasLongLength + ? reader.ReadInt64() + : reader.ReadInt32(); + var startPosition = reader.BaseStream.Position; + + + switch (key) + { + case "Layr": + case "Lr16": + case "Lr32": + result = new InfoLayers(reader, psdFile, key, length); + break; + case "lsct": + case "lsdk": + result = new LayerSectionInfo(reader, key, (int)length); + break; + case "luni": + result = new LayerUnicodeName(reader); + break; + case "lyid": + result = new LayerId(reader, key, length); + break; + default: + result = new RawLayerInfo(reader, signature, key, length); + break; + } + + // May have additional padding applied. + var endPosition = startPosition + length; + if (reader.BaseStream.Position < endPosition) + reader.BaseStream.Position = endPosition; + + // Documentation states that the length is even-padded. Actually: + // 1. Most keys have 4-padded lengths. + // 2. However, some keys (LMsk) have even-padded lengths. + // 3. Other keys (Txt2, Lr16, Lr32) have unpadded lengths. + // + // Photoshop writes data that is always 4-padded, even when the stated + // length is not a multiple of 4. The length mismatch seems to occur + // only on global layer info. We do not read extra padding in other + // cases because third-party programs are likely to follow the spec. + + if (globalLayerInfo) + { + reader.ReadPadding(startPosition, 4); + } + + //try if we can read the next signature + if (reader.BaseStream.Position < fileEndPos) + { + var nowPosition = reader.BaseStream.Position; + signature = reader.ReadAsciiChars(4); + if ((signature != "8BIM") && (signature != "8B64")) + { + hasLongLength = true; + reader.BaseStream.Position = baseStartPosition; + } + else + { + reader.BaseStream.Position = nowPosition; + breakFromLoop = true; + } + } + else + breakFromLoop = true; } - // May have additional padding applied. - var endPosition = startPosition + length; - if (reader.BaseStream.Position < endPosition) - reader.BaseStream.Position = endPosition; - - // Documentation states that the length is even-padded. Actually: - // 1. Most keys have 4-padded lengths. - // 2. However, some keys (LMsk) have even-padded lengths. - // 3. Other keys (Txt2, Lr16, Lr32) have unpadded lengths. - // - // Photoshop writes data that is always 4-padded, even when the stated - // length is not a multiple of 4. The length mismatch seems to occur - // only on global layer info. We do not read extra padding in other - // cases because third-party programs are likely to follow the spec. - - if (globalLayerInfo) - { - reader.ReadPadding(startPosition, 4); - } Util.DebugMessage(reader.BaseStream, "Load, End, LayerInfo, {0}, {1}", result.Signature, result.Key); @@ -105,6 +131,7 @@ internal static bool HasLongLength(string key, bool isLargeDocument) { return false; } + //return false; switch (key) { diff --git a/Editor/PSDPlugin/PsdFile/PsdFile.cs b/Editor/PSDPlugin/PsdFile/PsdFile.cs index 324a45d..6ef37fe 100644 --- a/Editor/PSDPlugin/PsdFile/PsdFile.cs +++ b/Editor/PSDPlugin/PsdFile/PsdFile.cs @@ -422,8 +422,8 @@ private void LoadLayerAndMaskInfo(PsdBinaryReader reader) while (reader.BaseStream.Position < endPosition) { var info = LayerInfoFactory.Load(reader, - psdFile: this, - globalLayerInfo: true); + psdFile: this, + globalLayerInfo: true, endPosition); AdditionalInfo.Add(info); if (info is RawLayerInfo) @@ -637,7 +637,7 @@ internal void VerifyLayerSections() foreach (var layer in Enumerable.Reverse(Layers)) { var layerSectionInfo = layer.AdditionalInfo.SingleOrDefault( - x => x is LayerSectionInfo); + x => x is LayerSectionInfo); if (layerSectionInfo == null) continue; diff --git a/Editor/SpriteData.cs b/Editor/SpriteData.cs index 22d446b..23678a1 100644 --- a/Editor/SpriteData.cs +++ b/Editor/SpriteData.cs @@ -26,7 +26,7 @@ public SpriteMetaData(SpriteRect sr) alignment = sr.alignment; border = sr.border; name = sr.name; - pivot = sr.pivot; + pivot = GetPivotValue(sr.alignment, sr.pivot); rect = sr.rect; spriteID = sr.spriteID; } diff --git a/Tests/EditorTests/PSDImporterDataProviderTests.cs b/Tests/EditorTests/PSDImporterDataProviderTests.cs index 08d07f6..c5fda8c 100644 --- a/Tests/EditorTests/PSDImporterDataProviderTests.cs +++ b/Tests/EditorTests/PSDImporterDataProviderTests.cs @@ -6,6 +6,7 @@ using System.Linq; using NSubstitute; using UnityEditor.Experimental.U2D; +using UnityEditor.Experimental.U2D.Animation; using UnityEditor.Experimental.U2D.PSD; using UnityEngine.Experimental.U2D; @@ -270,5 +271,42 @@ public void SpriteMeshDataProvider_SetDataPersistAfterReimport() Assert.AreEqual(edges[i], testEdges[i]); } } + + [Test] + public void UserCreatedSpriteRect_AppearsBottomLeftInCharacterMode() + { + var so = new SerializedObject(m_Importer); + var textureImporterSettingsSP = so.FindProperty("m_TextureImporterSettings"); + textureImporterSettingsSP.FindPropertyRelative("m_SpriteMode").intValue = (int)SpriteImportMode.Multiple; + so.FindProperty("m_MosaicLayers").boolValue = true; + so.FindProperty("m_CharacterMode").boolValue = true; + so.ApplyModifiedProperties(); + + var spriteProvider = m_Importer.GetDataProvider(); + var textureDataProvider = spriteProvider.GetDataProvider(); + int width, height; + textureDataProvider.GetTextureActualWidthAndHeight(out width, out height); + var spriteRect = spriteProvider.GetSpriteRects().ToList(); + + spriteRect.Add(new SpriteRect() + { + border = Vector4.zero, + alignment = SpriteAlignment.Center, + name = "InsertedRect", + pivot = Vector2.zero, + rect = new Rect(width - width * 0.5f, height - height * 0.5f, width * 0.5f, height * 0.5f), + }); + var newSpriteID = spriteRect[spriteRect.Count - 1].spriteID; + spriteProvider.SetSpriteRects(spriteRect.ToArray()); + spriteProvider.Apply(); + + m_Importer.SaveAndReimport(); + var importer = AssetImporter.GetAtPath(m_Importer.assetPath) as PSDImporter; + var characterProvider = importer.GetDataProvider(); + var characterData = characterProvider.GetCharacterData(); + Assert.AreEqual(spriteRect.Count, characterData.parts.Length); + var insertedSpriteCharacterPart = characterData.parts.FirstOrDefault(x => x.spriteId == newSpriteID.ToString()); + Assert.AreEqual(new RectInt(0, 0, (int)(width * 0.5f), (int)(height * 0.5f)), insertedSpriteCharacterPart.spritePosition); + } } } diff --git a/Tests/EditorTests/PSDImporterTests.cs b/Tests/EditorTests/PSDImporterTests.cs index df3856a..8e1d03d 100644 --- a/Tests/EditorTests/PSDImporterTests.cs +++ b/Tests/EditorTests/PSDImporterTests.cs @@ -36,7 +36,7 @@ string CopyTestAssetFile(bool copyMetaFile = true) } [TestCase(EditorBehaviorMode.Mode2D, true)] - [TestCase(EditorBehaviorMode.Mode3D, false)] + [TestCase(EditorBehaviorMode.Mode3D, true)] public void EditorBehaviourModeImportTest(EditorBehaviorMode mode, bool expectSprite) { EditorSettings.defaultBehaviorMode = mode; @@ -122,7 +122,7 @@ public void PSBImportProduceGameObjectWithCorrectHierarchy() new GameObjectHierarchyNode() { name = "Black", - componentType = new[] { typeof(Transform), typeof(SpriteRenderer), typeof(SpriteSkin) }, + componentType = new[] { typeof(Transform), typeof(SpriteRenderer), typeof(SpriteSkin)}, children = new GameObjectHierarchyNode[0] }, @@ -159,7 +159,7 @@ private void VerifyGameObjectHierarchy(GameObject go, GameObjectHierarchyNode hi Assert.AreEqual(hierarchy.name, go.name); Assert.AreEqual(hierarchy.children.Length, go.transform.childCount); var components = go.GetComponents(typeof(Component)); - Assert.AreEqual(hierarchy.componentType.Length, components.Length); + Assert.LessOrEqual(hierarchy.componentType.Length, components.Length); foreach (var component in hierarchy.componentType) { Assert.NotNull(components.SingleOrDefault(x => x.GetType() == component)); diff --git a/package.json b/package.json index a0a7092..a34a6ad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.unity.2d.psdimporter", - "version": "1.0.0-preview.1", + "version": "1.0.0-preview.2", "unity": "2018.3", "displayName": "2D PSD Importer", "description": "A ScriptedImporter for importing Adobe Photoshop file format. The ScriptedImporter is currently targeted for users who wants to create multi Sprite character animation using 2D Animation v2.", @@ -17,6 +17,6 @@ "repository": { "type": "git", "url": "https://gitlab.cds.internal.unity3d.com/upm-packages/2D/com.unity.2d.psdimporter.git", - "revision": "c83c993f53d4edcca09d1f8e6bb5710cd2956a19" + "revision": "2f0b4bdcc6ee5a7942a85118a5588289af5b8cbd" } }