Package Class
Namespace: Stride.Core.AssetsAssembly: Stride.Core.Assets.dll
A package managing assets.
[DataContract("Package")]
[AssetDescription(".sdpkg")]
[AssetFormatVersion("Assets", "3.1.0.0", "0.0.0.4")]
[AssetUpgrader("Assets", "0.0.0.4", "3.1.0.0", typeof(Package.MovePackageInsideProject))]
public sealed class Package : IFileSynchronizable, IAssetFinder
              | Name | Description | |
|---|---|---|
| Constructors | ||
| Package() | Initializes a new instance of the Package class.  | 
                          |
| Fields | ||
| PackageFileExtension | The file extension used for Package.  | 
                          |
| Properties | ||
| AssetFolders | Gets the asset directories to lookup.  | 
                          |
| Assets | Gets the assets stored in this package.  | 
                          |
| Bundles | Gets the bundles defined for this package.  | 
                          |
| Container | ||
| ExplicitFolders | Gets or sets the list of folders that are explicitly created but contains no assets.  | 
                          |
| FullPath | Gets the path to the package file. May be null if the package was not loaded or saved.  | 
                          |
| IsDirty | Gets or sets a value indicating whether this instance has been modified since last saving.  | 
                          |
| IsImplicitProject | ||
| IsSystem | Gets or sets a value indicating whether this package is a system package.  | 
                          |
| LoadedAssemblies | Gets the list of assemblies loaded by this package.  | 
                          |
| Meta | Gets or sets the metadata associated with this package.  | 
                          |
| OutputGroupDirectories | Gets the output group directories.  | 
                          |
| ResourceFolders | Gets the resource directories to lookup.  | 
                          |
| RootAssets | Asset references that needs to be compiled even if not directly or indirectly referenced (useful for explicit code references).  | 
                          |
| RootDirectory | Gets the top directory of this package on the local disk.  | 
                          |
| RootNamespace | ||
| SerializedVersion | Gets or sets the version number for this asset, used internally when migrating assets.  | 
                          |
| Session | Gets the session.  | 
                          |
| State | ||
| TemplateFolders | Gets the template folders.  | 
                          |
| Templates | Gets the loaded templates from the TemplateFolders  | 
                          |
| TemporaryAssets | Gets the temporary assets list loaded from disk before they are going into Assets.  | 
                          |
| UserSettings | Gets the package user settings. Usually stored in a .user file alongside the package. Lazily loaded on first time.  | 
                          |
| Methods | ||
| AddExistingProject(UFile) | Adds an existing project to this package.  | 
                          |
| AddExistingProject(UFile, LoggerResult) | Adds an existing project to this package.  | 
                          |
| Clone() | Deep clone this package.  | 
                          |
| FindAsset(AssetId) | Finds an asset by its identifier.  | 
                          |
| FindAsset(UFile) | Finds an asset by its location.  | 
                          |
| FindAssetFromProxyObject(Object) | Finds an asset from a proxy object.  | 
                          |
| FindAssetsInProject(String, out String) | ||
| GetDefaultAssetFolder() | ||
| GetPackageIdFromFile(String) | Gets the package identifier from file.  | 
                          |
| ListAssetFiles(ILogger, Package, Boolean, Boolean, Nullable<CancellationToken>) | ||
| Load(ILogger, String, PackageLoadParameters) | Loads only the package description but not assets or plugins.  | 
                          |
| LoadProject(ILogger, String) | ||
| LoadTemporaryAssets(ILogger, List<PackageLoadingAssetFile>, Nullable<CancellationToken>, Boolean, Func<PackageLoadingAssetFile, Boolean>) | Refreshes this package from the disk by loading or reloading all assets.  | 
                          |
| SaveSingleAsset(AssetItem, ILogger) | ||
| SetPackagePath(UFile, Boolean) | Sets the package path.  | 
                          |
| UpdateAssemblyReferences(ILogger, PackageLoadParameters) | Loads the assembly references that were not loaded before.  | 
                          |
| ValidateAssets(Boolean, Boolean, ILogger) | ||
| Events | ||
| AssetDirtyChanged | Occurs when an asset dirty changed occurred.  | 
                          |
| PackageDirtyChanged | Occurs when package dirty changed occurred.  | 
                          |
Constructors
Package()
Initializes a new instance of the Package class.
public Package()
              Fields
PackageFileExtension
The file extension used for Package.
public const string PackageFileExtension = ".sdpkg"
              Field Value
| Type | Description | 
|---|---|
| System.String | 
Properties
AssetFolders
Gets the asset directories to lookup.
[DataMember(40, DataMemberMode.Assign)]
public AssetFolderCollection AssetFolders { get; set; }
              Property Value
| Type | Description | 
|---|---|
| AssetFolderCollection | The asset directories.  | 
                  
Assets
Gets the assets stored in this package.
public PackageAssetCollection Assets { get; }
              Property Value
| Type | Description | 
|---|---|
| PackageAssetCollection | The assets.  | 
                  
Bundles
Gets the bundles defined for this package.
[DataMember(80)]
public BundleCollection Bundles { get; }
              Property Value
| Type | Description | 
|---|---|
| BundleCollection | The bundles.  | 
                  
Container
public PackageContainer Container { get; }
              Property Value
| Type | Description | 
|---|---|
| PackageContainer | 
ExplicitFolders
Gets or sets the list of folders that are explicitly created but contains no assets.
[DataMember(70)]
public List<UDirectory> ExplicitFolders { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<Stride.Core.IO.UDirectory> | 
FullPath
Gets the path to the package file. May be null if the package was not loaded or saved.
public UFile FullPath { get; set; }
              Property Value
| Type | Description | 
|---|---|
| Stride.Core.IO.UFile | The package path.  | 
                  
IsDirty
Gets or sets a value indicating whether this instance has been modified since last saving.
public bool IsDirty { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
                  
IsImplicitProject
public bool IsImplicitProject { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
IsSystem
Gets or sets a value indicating whether this package is a system package.
public bool IsSystem { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Boolean | 
  | 
                  
LoadedAssemblies
Gets the list of assemblies loaded by this package.
public List<PackageLoadedAssembly> LoadedAssemblies { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<PackageLoadedAssembly> | The loaded assemblies.  | 
                  
Meta
Gets or sets the metadata associated with this package.
[DataMember(10)]
public PackageMeta Meta { get; set; }
              Property Value
| Type | Description | 
|---|---|
| PackageMeta | The meta.  | 
                  
OutputGroupDirectories
Gets the output group directories.
[DataMember(50, DataMemberMode.Assign)]
public Dictionary<string, UDirectory> OutputGroupDirectories { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.Dictionary<System.String, Stride.Core.IO.UDirectory> | The output group directories.  | 
                  
ResourceFolders
Gets the resource directories to lookup.
[DataMember(45, DataMemberMode.Assign)]
public List<UDirectory> ResourceFolders { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<Stride.Core.IO.UDirectory> | The resource directories.  | 
                  
RootAssets
Asset references that needs to be compiled even if not directly or indirectly referenced (useful for explicit code references).
[DataMember(100)]
public RootAssetCollection RootAssets { get; }
              Property Value
| Type | Description | 
|---|---|
| RootAssetCollection | 
RootDirectory
Gets the top directory of this package on the local disk.
public UDirectory RootDirectory { get; }
              Property Value
| Type | Description | 
|---|---|
| Stride.Core.IO.UDirectory | The top directory.  | 
                  
RootNamespace
public string RootNamespace { get; }
              Property Value
| Type | Description | 
|---|---|
| System.String | 
SerializedVersion
Gets or sets the version number for this asset, used internally when migrating assets.
[DataMember(-8000, DataMemberMode.Assign)]
[DataStyle(DataStyle.Compact)]
[Display(null, null, Browsable = false)]
public Dictionary<string, PackageVersion> SerializedVersion { get; set; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.Dictionary<System.String, Stride.Core.PackageVersion> | The version.  | 
                  
Session
Gets the session.
public PackageSession Session { get; }
              Property Value
| Type | Description | 
|---|---|
| PackageSession | The session.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.InvalidOperationException | Cannot attach a package to more than one session  | 
                  
State
public PackageState State { get; set; }
              Property Value
| Type | Description | 
|---|---|
| PackageState | 
TemplateFolders
Gets the template folders.
[DataMember(90)]
public List<TemplateFolder> TemplateFolders { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<TemplateFolder> | The template folders.  | 
                  
Templates
Gets the loaded templates from the TemplateFolders
public List<TemplateDescription> Templates { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<TemplateDescription> | The templates.  | 
                  
TemporaryAssets
Gets the temporary assets list loaded from disk before they are going into Assets.
public List<AssetItem> TemporaryAssets { get; }
              Property Value
| Type | Description | 
|---|---|
| System.Collections.Generic.List<AssetItem> | The temporary assets.  | 
                  
UserSettings
Gets the package user settings. Usually stored in a .user file alongside the package. Lazily loaded on first time.
public PackageUserSettings UserSettings { get; }
              Property Value
| Type | Description | 
|---|---|
| PackageUserSettings | The package user settings.  | 
                  
Methods
AddExistingProject(UFile)
Adds an existing project to this package.
public LoggerResult AddExistingProject(UFile pathToMsproj)
              Parameters
| Type | Name | Description | 
|---|---|---|
| Stride.Core.IO.UFile | pathToMsproj | The path to msproj.  | 
                  
Returns
| Type | Description | 
|---|---|
| LoggerResult | LoggerResult.  | 
                  
AddExistingProject(UFile, LoggerResult)
Adds an existing project to this package.
public void AddExistingProject(UFile pathToMsproj, LoggerResult logger)
              Parameters
| Type | Name | Description | 
|---|---|---|
| Stride.Core.IO.UFile | pathToMsproj | The path to msproj.  | 
                  
| LoggerResult | logger | The logger.  | 
                  
Clone()
Deep clone this package.
public Package Clone()
              Returns
| Type | Description | 
|---|---|
| Package | The package cloned.  | 
                  
FindAsset(AssetId)
Finds an asset by its identifier.
public AssetItem FindAsset(AssetId assetId)
              Parameters
| Type | Name | Description | 
|---|---|---|
| AssetId | assetId | The identifier of the asset.  | 
                  
Returns
| Type | Description | 
|---|---|
| AssetItem | The corresponding AssetItem if found; otherwise,   | 
                  
Remarks
Looks for the asset amongst the current package and its dependencies.
FindAsset(UFile)
Finds an asset by its location.
public AssetItem FindAsset(UFile location)
              Parameters
| Type | Name | Description | 
|---|---|---|
| Stride.Core.IO.UFile | location | The location of the asset.  | 
                  
Returns
| Type | Description | 
|---|---|
| AssetItem | The corresponding AssetItem if found; otherwise,   | 
                  
Remarks
Looks for the asset amongst the current package and its dependencies.
FindAssetFromProxyObject(Object)
Finds an asset from a proxy object.
public AssetItem FindAssetFromProxyObject(object proxyObject)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | proxyObject | The proxy object which is represent the targeted asset.  | 
                  
Returns
| Type | Description | 
|---|---|
| AssetItem | The corresponding AssetItem if found; otherwise,   | 
                  
Remarks
Looks for the asset amongst the current package and its dependencies.
FindAssetsInProject(String, out String)
public static List<(UFile FilePath, UFile Link)> FindAssetsInProject(string projectFullPath, out string nameSpace)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | projectFullPath | |
| System.String | nameSpace | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<System.ValueTuple<Stride.Core.IO.UFile, Stride.Core.IO.UFile>> | 
GetDefaultAssetFolder()
public UDirectory GetDefaultAssetFolder()
              Returns
| Type | Description | 
|---|---|
| Stride.Core.IO.UDirectory | 
GetPackageIdFromFile(String)
Gets the package identifier from file.
public static Guid GetPackageIdFromFile(string filePath)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.String | filePath | The file path.  | 
                  
Returns
| Type | Description | 
|---|---|
| System.Guid | Guid.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | log or filePath  | 
                  
ListAssetFiles(ILogger, Package, Boolean, Boolean, Nullable<CancellationToken>)
public static List<PackageLoadingAssetFile> ListAssetFiles(ILogger log, Package package, bool listAssetsInMsbuild, bool listUnregisteredAssets, CancellationToken? cancelToken)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ILogger | log | |
| Package | package | |
| System.Boolean | listAssetsInMsbuild | |
| System.Boolean | listUnregisteredAssets | |
| System.Nullable<System.Threading.CancellationToken> | cancelToken | 
Returns
| Type | Description | 
|---|---|
| System.Collections.Generic.List<PackageLoadingAssetFile> | 
Load(ILogger, String, PackageLoadParameters)
Loads only the package description but not assets or plugins.
public static Package Load(ILogger log, string filePath, PackageLoadParameters loadParametersArg = null)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ILogger | log | The log to receive error messages.  | 
                  
| System.String | filePath | The file path.  | 
                  
| PackageLoadParameters | loadParametersArg | The load parameters argument.  | 
                  
Returns
| Type | Description | 
|---|---|
| Package | A package.  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.ArgumentNullException | log or filePath  | 
                  
LoadProject(ILogger, String)
public static PackageContainer LoadProject(ILogger log, string filePath)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ILogger | log | |
| System.String | filePath | 
Returns
| Type | Description | 
|---|---|
| PackageContainer | 
LoadTemporaryAssets(ILogger, List<PackageLoadingAssetFile>, Nullable<CancellationToken>, Boolean, Func<PackageLoadingAssetFile, Boolean>)
Refreshes this package from the disk by loading or reloading all assets.
public void LoadTemporaryAssets(ILogger log, List<PackageLoadingAssetFile> assetFiles = null, CancellationToken? cancelToken = null, bool listAssetsInMsbuild = true, Func<PackageLoadingAssetFile, bool> filterFunc = null)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ILogger | log | The log.  | 
                  
| System.Collections.Generic.List<PackageLoadingAssetFile> | assetFiles | The asset files (loaded from ListAssetFiles(ILogger, Package, Boolean, Boolean, Nullable<CancellationToken>) if null).  | 
                  
| System.Nullable<System.Threading.CancellationToken> | cancelToken | The cancel token.  | 
                  
| System.Boolean | listAssetsInMsbuild | Specifies if we need to evaluate MSBuild files for assets.  | 
                  
| System.Func<PackageLoadingAssetFile, System.Boolean> | filterFunc | A function that will filter assets loading  | 
                  
Exceptions
| Type | Condition | 
|---|---|
| System.InvalidOperationException | Package RootDirectory is null or Package RootDirectory [{0}] does not exist.ToFormat(RootDirectory)  | 
                  
SaveSingleAsset(AssetItem, ILogger)
public static bool SaveSingleAsset(AssetItem asset, ILogger log)
              Parameters
| Type | Name | Description | 
|---|---|---|
| AssetItem | asset | |
| ILogger | log | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
SetPackagePath(UFile, Boolean)
Sets the package path.
public void SetPackagePath(UFile newPath, bool copyAssets = true)
              Parameters
| Type | Name | Description | 
|---|---|---|
| Stride.Core.IO.UFile | newPath | The new path.  | 
                  
| System.Boolean | copyAssets | if set to   | 
                  
UpdateAssemblyReferences(ILogger, PackageLoadParameters)
Loads the assembly references that were not loaded before.
public void UpdateAssemblyReferences(ILogger log, PackageLoadParameters loadParametersArg = null)
              Parameters
| Type | Name | Description | 
|---|---|---|
| ILogger | log | The log.  | 
                  
| PackageLoadParameters | loadParametersArg | The load parameters argument.  | 
                  
ValidateAssets(Boolean, Boolean, ILogger)
public void ValidateAssets(bool alwaysGenerateNewAssetId, bool removeUnloadableObjects, ILogger log)
              Parameters
| Type | Name | Description | 
|---|---|---|
| System.Boolean | alwaysGenerateNewAssetId | |
| System.Boolean | removeUnloadableObjects | |
| ILogger | log | 
Events
AssetDirtyChanged
Occurs when an asset dirty changed occurred.
public event DirtyFlagChangedDelegate<AssetItem> AssetDirtyChanged
              Event Type
| Type | Description | 
|---|---|
| DirtyFlagChangedDelegate<AssetItem> | 
PackageDirtyChanged
Occurs when package dirty changed occurred.
public event DirtyFlagChangedDelegate<Package> PackageDirtyChanged
              Event Type
| Type | Description | 
|---|---|
| DirtyFlagChangedDelegate<Package> |