Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [6.0.3] - 2022-02-07
### Fixed
- Fixed unable to change mipmap settings in inspector. (Case 1381198)
- Fixed null exception when importing files with masks. (Case 1397354)
  • Loading branch information
Unity Technologies committed Feb 7, 2022
1 parent 75f2693 commit edf1e3d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Changelog

## [6.0.3] - 2022-02-07
### Fixed
- Fixed unable to change mipmap settings in inspector. (Case 1381198)
- Fixed null exception when importing files with masks. (Case 1397354)

## [6.0.2] - 2021-11-24
### Fixed
- Fixed per platform settings does not get applied in Windows platform. (Case 1379970)
- Fixed unable to change mipmap settings in inspector. (Case 1381198)

## [6.0.1] - 2021-09-21
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Editor/PSDImporterEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ void MipMapGUI()
{
EditorGUI.indentLevel++;
ToggleFromInt(m_BorderMipMap, s_Styles.borderMipMaps);
EditorGUILayout.Popup(s_Styles.mipMapFilter, m_MipMapMode.intValue, s_Styles.mipMapFilterOptions);
m_MipMapMode.intValue = EditorGUILayout.Popup(s_Styles.mipMapFilter, m_MipMapMode.intValue, s_Styles.mipMapFilterOptions);

ToggleFromInt(m_MipMapsPreserveCoverage, s_Styles.mipMapsPreserveCoverage);
if (m_MipMapsPreserveCoverage.intValue != 0 && !m_MipMapsPreserveCoverage.hasMultipleDifferentValues)
Expand Down
36 changes: 35 additions & 1 deletion Editor/PSDPlugin/PsdFile/Layers/Mask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public Mask(Layer layer, Rectangle rect, byte color, BitVector32 flags)
/// </summary>
internal class MaskInfo
{
private static int s_UserMaskDensityBit = BitVector32.CreateMask();
private static int s_UserMaskFeatherBit = BitVector32.CreateMask(s_UserMaskDensityBit);
private static int s_VectorMaskDensityBit = BitVector32.CreateMask(s_UserMaskFeatherBit);
private static int s_VectorMaskFeatherBit = BitVector32.CreateMask(s_VectorMaskDensityBit);

public Mask LayerMask { get; set; }

public Mask UserMask { get; set; }
Expand All @@ -113,7 +118,7 @@ internal class MaskInfo
public MaskInfo()
{
}

public MaskInfo(PsdBinaryReader reader, Layer layer)
{
Util.DebugMessage(reader.BaseStream, "Load, Begin, MaskInfo");
Expand All @@ -139,6 +144,35 @@ public MaskInfo(PsdBinaryReader reader, Layer layer)
var userRectangle = reader.ReadRectangle();
UserMask = new Mask(layer, userRectangle, userBackgroundColor, new BitVector32(userFlagsByte));
}
else
{
// Only check if bit 4 is set. Testing shows there are discrepancy in file format documentation.
if (flagsByte == 16)
{
// Not using them so just read and discard the values
var maskParameters = new BitVector32(reader.ReadByte());
if (maskParameters[s_UserMaskDensityBit])
reader.ReadByte();

if (maskParameters[s_UserMaskFeatherBit])
reader.ReadDouble();

if (maskParameters[s_VectorMaskDensityBit])
reader.ReadByte();

if (maskParameters[s_VectorMaskFeatherBit])
reader.ReadDouble();
}

// The rest should be vector mask
if (reader.BaseStream.Position + 18 <= endPosition)
{
var userFlagsByte = reader.ReadByte();
var userBackgroundColor = reader.ReadByte();
var userRectangle = reader.ReadRectangle();
UserMask = new Mask(layer, userRectangle, userBackgroundColor, new BitVector32(userFlagsByte));
}
}

// 20-byte mask data will end with padding.
reader.BaseStream.Position = endPosition;
Expand Down
11 changes: 11 additions & 0 deletions Editor/PSDPlugin/PsdFile/PsdBinaryReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ public Int32 ReadInt32()
return val;
}

public double ReadDouble()
{
var val = reader.ReadDouble();
byte[] b = BitConverter.GetBytes(val);
{
Util.SwapBytes(b, 0, 8);
}
val = BitConverter.ToDouble(b, 0);
return val;
}

public Int64 ReadInt64()
{
var val = reader.ReadInt64();
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "com.unity.2d.psdimporter",
"version": "6.0.2",
"version": "6.0.3",
"unity": "2021.2",
"unityRelease": "7f1",
"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 @@ -11,19 +12,19 @@
],
"category": "2D",
"dependencies": {
"com.unity.2d.animation": "7.0.3",
"com.unity.2d.common": "6.0.2",
"com.unity.2d.animation": "7.0.4",
"com.unity.2d.common": "6.0.3",
"com.unity.2d.sprite": "1.0.0"
},
"relatedPackages": {
"com.unity.2d.psdimporter.tests": "6.0.2"
"com.unity.2d.psdimporter.tests": "6.0.3"
},
"upmCi": {
"footprint": "ba98f99ccbaa84a993003055774cd003dc4e4a5c"
"footprint": "d201ce7dd6bf474493bca45e8c571c4140e1f51b"
},
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/2d.git",
"type": "git",
"revision": "890da0579456dc5daa73a5645949c0615fac3d16"
"revision": "41fd674f8e4b2265bdbc50291dced1bd86c590ee"
}
}

0 comments on commit edf1e3d

Please sign in to comment.