Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [9.0.3] - 2024-04-01
### Fixed
- Fix source file cannot be deleted after subsequent import. (Case DANB-579)

### Changed
- Updated the Editor Analytics to use the latest APIs.
  • Loading branch information
Unity Technologies committed Apr 1, 2024
1 parent d5d4663 commit f0daf2a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [9.0.3] - 2024-04-01
### Fixed
- Fix source file cannot be deleted after subsequent import. (Case DANB-579)

### Changed
- Updated the Editor Analytics to use the latest APIs.

## [9.0.2] - 2024-02-06
### Fixed
- Provide custom packing override for users to override to address DANB-526. (Case DANB-526)
Expand Down
62 changes: 46 additions & 16 deletions Editor/Analytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ namespace UnityEditor.U2D.PSD
{
[Serializable]
internal struct PSDApplyEvent
#if USE_NEW_EDITOR_ANALYTICS
: IAnalytic.IData
#endif
{
public const string name = "psdImporterApply";

public int instance_id;
public int texture_type;
public int sprite_mode;
Expand All @@ -20,9 +25,32 @@ internal struct PSDApplyEvent
public SpriteAlignment character_alignment;
public bool is_psd;
public PsdColorMode color_mode;

}

#if USE_NEW_EDITOR_ANALYTICS
[AnalyticInfo(eventName: PSDApplyEvent.name,
vendorKey: Analytics.vendorKey,
version: Analytics.version,
maxEventsPerHour: Analytics.maxEventsPerHour,
maxNumberOfElements: Analytics.maxNumberOfElements)]
internal class PSDApplyEventAnalytic : IAnalytic
{
PSDApplyEvent m_EvtData;

public PSDApplyEventAnalytic(PSDApplyEvent evtData)
{
m_EvtData = evtData;
}

public bool TryGatherData(out IAnalytic.IData data, out Exception error)
{
data = m_EvtData;
error = null;
return true;
}
}
#endif

internal interface IAnalytics
{
AnalyticsResult SendApplyEvent(PSDApplyEvent evt);
Expand All @@ -31,34 +59,36 @@ internal interface IAnalytics
internal static class AnalyticFactory
{
static IAnalytics s_Analytics;
static public IAnalytics analytics

public static IAnalytics analytics
{
get
{
if (s_Analytics == null)
s_Analytics = new Analytics();
return s_Analytics;
}
set { s_Analytics = value; }
get => s_Analytics ??= new Analytics();
set => s_Analytics = value;
}
}

[InitializeOnLoad]
internal class Analytics : IAnalytics
{
const int k_MaxEventsPerHour = 100;
const int k_MaxNumberOfElements = 1000;
const string k_VendorKey = "unity.2d.psdimporter";
const int k_Version = 1;
public const int maxEventsPerHour = 100;
public const int maxNumberOfElements = 1000;
public const string vendorKey = "unity.2d.psdimporter";
public const int version = 1;

static Analytics()
{
EditorAnalytics.RegisterEventWithLimit("psdImporterApply", k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey, k_Version);
#if !USE_NEW_EDITOR_ANALYTICS
EditorAnalytics.RegisterEventWithLimit(PSDApplyEvent.name, maxEventsPerHour, maxNumberOfElements, vendorKey, version);
#endif
}

public AnalyticsResult SendApplyEvent(PSDApplyEvent evt)
{
return EditorAnalytics.SendEventWithLimit("psdImporterApply", evt, k_Version);
#if USE_NEW_EDITOR_ANALYTICS
return EditorAnalytics.SendAnalytic(new PSDApplyEventAnalytic(evt));
#else
return EditorAnalytics.SendEventWithLimit(PSDApplyEvent.name, evt, version);
#endif
}
}
}
}
11 changes: 7 additions & 4 deletions Editor/PSDPlugin/PsdFile/PsdFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ private void Load(Stream stream, LoadContext loadContext, ELoadFlag loadFlag)
LoadImage(reader);
DecompressImages();
}

reader.Dispose();
reader = null;
}

#endregion
Expand Down Expand Up @@ -557,10 +560,10 @@ internal void VerifyLayerSections()
if (depth < 0)
throw new PsdInvalidException("Layer section ended without matching start marker.");
break;

case LayerSectionType.Layer: // Nothing to do here yet.
break;

default:
throw new PsdInvalidException("Unrecognized layer section type.");
}
Expand Down Expand Up @@ -594,7 +597,7 @@ public void SetVersionInfo()
versionInfo.FileVersion = 1;
}
}


///////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -708,4 +711,4 @@ internal enum ImageCompression
/// </summary>
ZipPrediction = 3
}
}
}
5 changes: 5 additions & 0 deletions Editor/Unity.2D.Psdimporter.Editor.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"name": "com.unity.2d.animation",
"expression": "0.0.1",
"define": "ENABLE_2D_ANIMATION"
},
{
"name": "Unity",
"expression": "2023.2.0a22",
"define": "USE_NEW_EDITOR_ANALYTICS"
}
],
"noEngineReferences": false
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.unity.2d.psdimporter",
"version": "9.0.2",
"version": "9.0.3",
"unity": "2023.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.",
Expand All @@ -15,7 +15,7 @@
"com.unity.2d.sprite": "1.0.0"
},
"relatedPackages": {
"com.unity.2d.psdimporter.tests": "9.0.2"
"com.unity.2d.psdimporter.tests": "9.0.3"
},
"samples": [
{
Expand All @@ -25,15 +25,15 @@
}
],
"_upm": {
"changelog": "### Fixed\n- Provide custom packing override for users to override to address DANB-526. (Case DANB-526)\n- Fixed layers are not shown in LayerImportSettings after unselecting all layers and applying. (Case DANB-569)"
"changelog": "### Fixed\n- Fix source file cannot be deleted after subsequent import. (Case DANB-579)\n\n### Changed\n- Updated the Editor Analytics to use the latest APIs."
},
"upmCi": {
"footprint": "d8630d2026a2a1f0ccffccd1458e4ec610fda110"
"footprint": "ec7f070542925957d8aeffef11be9cd939d31bd7"
},
"documentationUrl": "https://docs.unity3d.com/Packages/[email protected]/manual/index.html",
"repository": {
"url": "https://github.cds.internal.unity3d.com/unity/2d.git",
"type": "git",
"revision": "de1d2b0a924b0621324b0cfe0fcbef92f03bd2c2"
"revision": "cacb780673a1e5d1e9bd0e398015b1a9924c0922"
}
}

0 comments on commit f0daf2a

Please sign in to comment.