Class AssetResolver
Helper to find available new asset locations and identifiers.
public sealed class AssetResolver
- Inheritance
-
AssetResolver
Constructors
AssetResolver()
Initializes a new instance of the AssetResolver class.
public AssetResolver()
AssetResolver(ContainsLocationDelegate, ContainsAssetWithIdDelegate)
Initializes a new instance of the AssetResolver class.
public AssetResolver(NamingHelper.ContainsLocationDelegate containsLocation, AssetResolver.ContainsAssetWithIdDelegate containsAssetWithId)
Parameters
containsLocation
NamingHelper.ContainsLocationDelegateThe delegate used to check if an asset location is already used.
containsAssetWithId
AssetResolver.ContainsAssetWithIdDelegateThe delegate used to check if an asset identifier is already used.
Properties
AlwaysCreateNewId
Gets or sets a value indicating whether to always generate a new id on RegisterId(AssetId, out AssetId).
public bool AlwaysCreateNewId { get; set; }
Property Value
- bool
true
if [force new identifier]; otherwise,false
.
ContainsAssetWithId
Gets or sets a delegate to test if an asset id is already used.
public AssetResolver.ContainsAssetWithIdDelegate ContainsAssetWithId { get; set; }
Property Value
- AssetResolver.ContainsAssetWithIdDelegate
A delegate to test if an asset id is already used.
ContainsLocation
Gets or sets a delegate to test if a location is already used.
public NamingHelper.ContainsLocationDelegate ContainsLocation { get; set; }
Property Value
- NamingHelper.ContainsLocationDelegate
A delegate to test if a location is already used.
ExistingIds
Gets the asset ids already used.
public HashSet<AssetId> ExistingIds { get; }
Property Value
ExistingLocations
Gets the locations already used.
public HashSet<string> ExistingLocations { get; }
Property Value
Methods
FromPackage(Package)
Creates a new AssetResolver using an existing package to check the existence of asset locations and ids.
public static AssetResolver FromPackage(Package package)
Parameters
package
PackageThe package.
Returns
- AssetResolver
A new AssetResolver.
Exceptions
- ArgumentNullException
package
FromPackage(IList<Package>)
Creates a new AssetResolver using an existing package to check the existence of asset locations and ids.
public static AssetResolver FromPackage(IList<Package> packages)
Parameters
Returns
- AssetResolver
A new AssetResolver.
Exceptions
- ArgumentNullException
package
RegisterId(AssetId, out AssetId)
Registers an asset identifier for usage.
public bool RegisterId(AssetId assetId, out AssetId newGuid)
Parameters
assetId
AssetIdThe asset identifier.
newGuid
AssetIdThe new unique identifier if an asset has already been registered with the same id.
Returns
- bool
true
if the asset id is already in used.newGuid
contains a new guid,false
otherwise.
RegisterLocation(UFile, out UFile)
Finds a name available for a new asset. This method will try to create a name based on an existing name and will append "_" + (number++) on every try. The new location found is added to the known existing locations.
public bool RegisterLocation(UFile location, out UFile newLocation)
Parameters
location
UFileThe location.
newLocation
UFileThe new location.
Returns
- bool
true
if there is a new location,false
otherwise.