Skip to content

PackageLicenseService

ClassAssetInventoryAssetInventory.Editor
public static class PackageLicenseService

Owns selected-license mutations, source authority, immutable evidence and catalog identity.

public const string StandardLicenseName = "Standard Unity Asset Store EULA"

Returns

System.String

public const string NonStandardLicenseName = "Non standard EULA"

Returns

System.String

public const string StandardLicenseUrl = "https://unity.com/legal/as-terms"

Returns

System.String

public const string CurrentSourceOptionPrefix = "remote-current-"

Returns

System.String

public static PackageLicense ReadLicense(Asset asset)

Reads a package's complete license as stored now, for edits and decisions that write. Name and link come from the given record.

Parameters

Name Type
asset AssetInventory.Asset

Returns

AssetInventory.PackageLicense

public static PackageLicense ReadLicense(AssetInfo info)

Reads a package's complete license from a snapshot of the small selection table, for display and reports over many packages.

Parameters

Name Type
info AssetInventory.AssetInfo

Returns

AssetInventory.PackageLicense

public static T CloneData<T>(T value)

Creates an independent JSON copy using the license-data serialization settings.

Parameters

Name Type
value {T}

Returns

{T}

CopySelection(PackageLicense, PackageLicense)

Section titled “CopySelection(PackageLicense, PackageLicense)”
public static void CopySelection(PackageLicense source, PackageLicense target)

Copies selected terms, source identity, document evidence and additional choice data into another working license.

Parameters

Name Type
source AssetInventory.PackageLicense
target AssetInventory.PackageLicense
public static void CopySelection(PackageLicense source, Asset target)

Copies the selected license name and location into package metadata.

Parameters

Name Type
source AssetInventory.PackageLicense
target AssetInventory.Asset
public static void CopySelection(Asset source, Asset target)

Copies license name and location between package metadata records.

Parameters

Name Type
source AssetInventory.Asset
target AssetInventory.Asset

SameSelection(PackageLicense, PackageLicense)

Section titled “SameSelection(PackageLicense, PackageLicense)”
public static bool SameSelection(PackageLicense first, PackageLicense second)

Whether two working copies record the same choice. A license that follows its source takes its document from the source, so only a pinned one compares it.

Parameters

Name Type
first AssetInventory.PackageLicense
second AssetInventory.PackageLicense

Returns

System.Boolean

public static LicenseData ReadData(string json, out string error)

Reads an editable copy. Resolution uses a separately cached immutable view.

Parameters

Name Type
json System.String
error System.String

Returns

AssetInventory.LicenseData

public static string SerializeData(LicenseData data)

Validates and serializes additional license choices, returning null when no choices or selected snapshot remain.

Parameters

Name Type
data AssetInventory.LicenseData

Returns

System.String

ValidateSelection(PackageLicense, out string)

Section titled “ValidateSelection(PackageLicense, out string)”
public static bool ValidateSelection(PackageLicense selection, out string error)

Checks that a working license contains readable choice data and names for its options and required agreements.

Parameters

Name Type
selection AssetInventory.PackageLicense
error System.String

Returns

System.Boolean

public static bool HasConditions(LicenseConditions conditions)

Returns whether any review requirement, contractual note, revenue limit or validity date is recorded.

Parameters

Name Type
conditions AssetInventory.LicenseConditions

Returns

System.Boolean

public static bool SelectOption(PackageLicense draft, string optionId)

Selects an available option from a draft and snapshots its required agreements and conditions.

Parameters

Name Type
draft AssetInventory.PackageLicense
optionId System.String

Returns

System.Boolean

SelectOption(PackageLicense, LicenseData, string)

Section titled “SelectOption(PackageLicense, LicenseData, string)”
public static bool SelectOption(PackageLicense draft, LicenseData data, string optionId)

Applies an available option from supplied choice data to a draft, preserving a snapshot of its agreements and conditions.

Parameters

Name Type
draft AssetInventory.PackageLicense
data AssetInventory.LicenseData
optionId System.String

Returns

System.Boolean

public static void ClearSelection(PackageLicense draft)

Clears a draft's selected terms while retaining its available license options.

Parameters

Name Type
draft AssetInventory.PackageLicense
public static bool CanUseStoreLicense(Asset asset)

Store evidence applies only to rows whose own source is that Store product.

Parameters

Name Type
asset AssetInventory.Asset

Returns

System.Boolean

public static bool CanUseStoreLicense(PackageLicense license)

Store evidence applies only to rows whose own source is that Store product.

Parameters

Name Type
license AssetInventory.PackageLicense

Returns

System.Boolean

public static string StoreLicenseName(AssetStoreLicenseKind kind)

The license name that stands for a Store observation, null while it is unknown.

Parameters

Name Type
kind AssetInventory.AssetStoreLicenseKind

Returns

System.String

GetChangedSourceOption(PackageLicense, LicenseData)

Section titled “GetChangedSourceOption(PackageLicense, LicenseData)”
public static LicenseOption GetChangedSourceOption(PackageLicense selection, LicenseData data)

The source's current license when it differs from the applied one, so it can be reviewed explicitly.

Parameters

Name Type
selection AssetInventory.PackageLicense
data AssetInventory.LicenseData

Returns

AssetInventory.LicenseOption

UseStoreLicense(PackageLicense, AssetStoreLicense)

Section titled “UseStoreLicense(PackageLicense, AssetStoreLicense)”
public static void UseStoreLicense(PackageLicense draft, AssetStoreLicense cache)

Applies matching cached Asset Store license evidence to a draft while retaining any alternative choices.

Parameters

Name Type
draft AssetInventory.PackageLicense
cache AssetInventory.AssetStoreLicense
public static bool IsProtected(Asset asset)

Returns whether provider refreshes must preserve a package's current license choice or additional data.

Parameters

Name Type
asset AssetInventory.Asset

Returns

System.Boolean

public static bool IsProtected(PackageLicense license)

Returns whether a license selection is manual, cleared, overridden or contains additional data that provider refreshes must preserve.

Parameters

Name Type
license AssetInventory.PackageLicense

Returns

System.Boolean

ApplyProvider(Asset, string, string, string)

Section titled “ApplyProvider(Asset, string, string, string)”
public static bool ApplyProvider(Asset target, string name, string url, string sourceKey)

Applies only provider-owned or missing data to the name and link. The caller persists a freshly reloaded package.

Parameters

Name Type
target AssetInventory.Asset
name System.String
url System.String
sourceKey System.String

Returns

System.Boolean

ApplyOverride(PackageLicense, string, string, string, bool, string, string)

Section titled “ApplyOverride(PackageLicense, string, string, string, bool, string, string)”
public static bool ApplyOverride(PackageLicense target, string name, string url, string licenseData = null, bool clear = false, string documentHash = null, string sourceKey = null)

Applies an explicit override to a working license, optionally clearing its selected terms without persisting the draft.

Parameters

Name Type
target AssetInventory.PackageLicense
name System.String
url System.String
licenseData System.String
clear System.Boolean
documentHash System.String
sourceKey System.String

Returns

System.Boolean

public static void SaveOverride(Asset package, PackageLicense license)

Stores the details of an applied override once the package record is persisted.

Parameters

Name Type
package AssetInventory.Asset
license AssetInventory.PackageLicense

SaveSelection(PackageLicense, PackageLicense, out string, bool)

Section titled “SaveSelection(PackageLicense, PackageLicense, out string, bool)”
public static bool SaveSelection(PackageLicense draft, PackageLicense baseline, out string error, bool allowUnsupportedReplacement = false)

Validates and persists a license draft against its baseline, reporting conflicting edits instead of overwriting them.

Parameters

Name Type
draft AssetInventory.PackageLicense
baseline AssetInventory.PackageLicense
error System.String
allowUnsupportedReplacement System.Boolean

Returns

System.Boolean

SavePackageData(Asset, PackageLicense, PackageLicense, out string, bool)

Section titled “SavePackageData(Asset, PackageLicense, PackageLicense, out string, bool)”
public static bool SavePackageData(Asset package, PackageLicense draft, PackageLicense baseline, out string error, bool allowUnsupportedReplacement = false)

Persists package metadata together with license changes in one transaction while protecting concurrent license edits.

Parameters

Name Type
package AssetInventory.Asset
draft AssetInventory.PackageLicense
baseline AssetInventory.PackageLicense
error System.String
allowUnsupportedReplacement System.Boolean

Returns

System.Boolean

SetManualSelection(PackageLicense, string, string)

Section titled “SetManualSelection(PackageLicense, string, string)”
public static void SetManualSelection(PackageLicense draft, string name, string url)

Sets manual terms on a draft and updates its selected-option data without persisting the changes.

Parameters

Name Type
draft AssetInventory.PackageLicense
name System.String
url System.String
public static string StoreSourceKey(int productId)

Builds the stable license-authority key for a Unity Asset Store product.

Parameters

Name Type
productId System.Int32

Returns

System.String

public static string GetSourceKey(Asset asset)

Gets a package's source-authority key, or null when its source has no recorded authority identity.

Parameters

Name Type
asset AssetInventory.Asset

Returns

System.String

public static string GetSourceKey(AssetInfo asset)

Gets a displayed package's source-authority key, or null when its source has no recorded authority identity.

Parameters

Name Type
asset AssetInventory.AssetInfo

Returns

System.String

public static string GetSourceKey(PackageLicense license)

Gets the source-authority key represented by a working license's package identity.

Parameters

Name Type
license AssetInventory.PackageLicense

Returns

System.String

public static void RecordSourceChange(Asset package)

Call before persisting a package whose identity may have changed. A license taken from the old source stays bound to it and needs review instead of silently following the new one.

Parameters

Name Type
package AssetInventory.Asset
public static void InheritSelection(Asset child)

A new nested package takes over its parent's license details together with the name and link it copied.

Parameters

Name Type
child AssetInventory.Asset
public static void DeleteSelection(int assetId)

Removes the selection of a package that is being deleted.

Parameters

Name Type
assetId System.Int32
public static AssetStoreLicense GetCache(int productId)

Reads cached Asset Store license evidence for a product, returning null when no evidence is available.

Parameters

Name Type
productId System.Int32

Returns

AssetInventory.AssetStoreLicense

public static string StoreDocument(string content, string mediaType = "text/plain", bool retain = false)

Stores agreement text under its UTF-8 SHA-256 content identity and returns that identity.

Parameters

Name Type
content System.String
mediaType System.String
retain System.Boolean

Returns

System.String

public static LicenseDocument GetDocument(string hash)

Reads and verifies a cached agreement by its content hash and updates its last-access time.

Parameters

Name Type
hash System.String

Returns

AssetInventory.LicenseDocument

public static void RetainDocuments(PackageLicense selection)

Marks the selected license document and required agreement documents for retention during cache pruning.

Parameters

Name Type
selection AssetInventory.PackageLicense
public static void MergeSelection(Asset survivor, Asset duplicate)

Merges a duplicate's selection into the survivor. The survivor's name and link change in memory for the caller to persist; its selection row is written here.

Parameters

Name Type
survivor AssetInventory.Asset
duplicate AssetInventory.Asset
public static string GetCatalogId()

Gets or creates the persistent identity of the current catalog used by project license references.

Returns

System.String

public static void RecordMerge(int oldId, int newId)

Records license-source aliases from an existing package identifier to its surviving package identifier.

Parameters

Name Type
oldId System.Int32
newId System.Int32
public static void RecordMerge(Asset removed, Asset survivor)

Records a caller-verified identity merge using the final survivor identity before the old row is removed.

Parameters

Name Type
removed AssetInventory.Asset
survivor AssetInventory.Asset

IsVerifiedSourceMigration(PackageLicense, string)

Section titled “IsVerifiedSourceMigration(PackageLicense, string)”
public static bool IsVerifiedSourceMigration(PackageLicense package, string sourceKey)

Checks persisted merge evidence that a source-authority key belongs to the package's current identity.

Parameters

Name Type
package AssetInventory.PackageLicense
sourceKey System.String

Returns

System.Boolean

public static int ResolveAssetId(int assetId)

Follows recorded merge aliases to the current package identifier, returning zero for invalid or cyclic alias chains.

Parameters

Name Type
assetId System.Int32

Returns

System.Int32

public static void NotifyChanged()

Invalidates cached license lookups, advances the revision and queues a consolidated editor change notification.

public static int Revision { get; }

Returns

System.Int32

public static event Action Changed

Raised on the editor thread after license-data change notifications have been consolidated.

Returns

System.Action