class
ProjectLibrary
Project library is the primary location for interacting with all the resources in the current project.
A complete hierarchy of resources is provided which can be interacted with by importing new ones, deleting them, moving, renaming and similar.
Public
Constructors
ProjectLibrary
Methods
~ProjectLibrary
SaveResourceAs
Registers a new resource in the library.
- resource
- Resource instance to add to the library. A copy of the resource will be saved at the provided path.
- relativePath
- Path where where to store the resource, relative to the project library imported resources folder.
Returns: Operation result and optional error message if failed.
SaveResource
Re-saves an existing resource in the library.
Returns: Operation result and optional error message if failed.
Import
Imports a new resource from the provided path.
Destination path must not contain a file or import will fail.
- sourceResourcePath
- Absolute path to the source resource to import.
- destinationFolderRelativePath
- Path to the folder where the imported resources will be stored. Relative to the project library imported resources folder.
- importOptions
- Options used to control the import. Must match the imported file type.
Returns: Operation result and optional error message if failed.
ImportSynchronized
Similar to Import(), but also copies the source resource into the project library 'Resources/Source/' folder.
Imported packages will be linked with the source resource.
Performing move, rename, copy or delete operation on such entries will also apply the same operation to the source resource in the 'Resources/Source/' folder. Both the source and imported asset will be placed at the same relative path in 'Resources/Source/' and 'Resources/Imported' folders, respectively. You will not be able to edit, move, rename or delete synchronized sub-resources individually. You will only be able to reimport the entirety of the source resource.
- sourceResourcePath
- Absolute path to the source resource to import.
- destinationFolderRelativePath
- Path to the folder where the imported resources will be stored. Relative to the project library imported resources folder.
- importOptions
- Options used to control the import. Must match the imported file type.
Returns: Operation result and optional error message if failed.
Reimport
Re-imports the resource at the provided path.
Source file to reimport from will be looked up from the existing resource meta-data. Note that if the resource was imported using ImportSynchronized(), you should call ReimportSynchronized() instead, otherwise the operation will fail and individual sub-resources cannot be updated when they are synchronized with their source asset.
- relativePath
- Path where the existing resource is stored, relative to the project library imported resource folder.
- importOptions
- Import options to import the source resource with. Can be null, in which case previously used import options will be used.
Returns: Operation result and optional error message if failed.
ReimportSynchronized
Re-imports the synchronized source resource associated with the provided path.
The operation will fail if the resource at the provided path was not imported via ImportSynchronized(). All imported resources from the source resource will be overwritten from the newly imported data, and resources that not longer exist in the source resource will be deleted.
- relativePath
- Path to the synchronized package entry, relative to the project library imported resource folder.
- importOptions
- Import options to import the source resource with. Can be null, in which case previously used import options will be used.
Returns: Operation result and optional error message if failed.
Move
Moves a file or folder from one location to another.
If the entry is a folder, all the children will be moved as well. If destination already contains an entry with the same name, the move operation will be skipped for that source entry - except if both source and destination is a folder, in which case their contents will be merged.
- sourceRelativePath
- Path of the file or folder to move. Relative to the project library imported resources folder.
- destinationRelativePath
- Path to the new location of the source file or folder. Relative to the project library imported resources folder.
Returns: Operation result and optional error message if failed.
Copy
Copies a file or folder from one location to another.
If the entry is a folder, all the children will be copied as well. If destination already contains an entry with the same name, the copy operation will be skipped for that source entry - except if both source and destination is a folder, in which case their contents will be merged.
- sourceRelativePath
- Path of the file or folder to copy. Relative to the project library imported resources folder.
- destinationRelativePath
- Path to the location where to place the copied file or folder. Relative to the project library imported resources folder.
Returns: Operation result and optional error message if failed.
Delete
Deletes a file or a folder at the specified path.
If the entry is a folder, all the children will be deleted as well.
- relativePath
- Path to the file or folder to delete. relative to the project library imported resources folder.
Returns: Operation result and optional error message if failed.
CreateFolder
Creates a folder at the specified path.
- folderRelativePath
- Path to the folder to create, relative to the project library imported resources folder.
Returns: Operation result and optional error message if failed.
SetMetaData
Associates meta-data with the specified resource.
Meta-data can be anything, but should be kept small.
- resourceId
- ID of the resource whose meta-data to update.
- metaData
- Meta-data to set.
SetIncludeInBuild
Updates the include-in-build flag on the specified resource.
When enabled, the resource is guaranteed to be included in the build, even if not referenced by anything. If false, only resources that are referenced by other resources and the default scene list will be included in the build.
- resourceId
- ID of the resource whose flag to update.
- includeInBuild
- Value to set.
FindEntry
Attempts to a find a library entry at the specified path.
- relativePath
- Path to the entry to search. Relative to the project library imported resources folder.
Returns: Found entry, or null if not found.
FindEntry
Attempts to find a library resource entry from the resource ID.
- resourceId
- ID of the resource to find.
Returns: Found entry, or null if not found.
Search
Searches the library for a pattern and returns all entries matching it.
- pattern
- Pattern to search for. Use wildcard * to match any character(s).
Returns: A list of entries matching the pattern.
Search
Searches the library for a pattern, but only among specific resource types.
- pattern
- Pattern to search for. Use wildcard * to match any character(s).
- typeIds
- RTTI type IDs of the resource types to limit the search for.
Returns: A list of entries matching the pattern.
Search
Searches a particular folder or package for a pattern, but only among specific resource types.
- relativePath
- Path to the folder or package to search.
- pattern
- Pattern to search for. Use wildcard * to match any character(s).
- typeIds
- RTTI type IDs of the resource types to limit the search for.
- recurse
- If true, child folders or packages of the current folder will also be searched.
Returns: A list of entries matching the pattern.
GetResourcesIncludedInBuild
Returns a list of all resources with IncludedInBuild property set to true.
Exists
Checks if the specified path exists in the library.
- relativePath
- Path to the entry to look up. Relative to the project library imported resources folder.
Returns: True if found an existing entry, false otherwise.
Exists
Checks if resource with the specified ID exists in the library.
- resourceId
- ID to the entry to look up.
Returns: True if found an existing entry, false otherwise.
CheckSourceResourceFolderForChanges
Scans the Resources/Source folder for any changes and automatically triggers import, reimport or delete operations depending on the change: - If a source resource file is found that is not present in the database, import operation is triggered - If a source resource file is found that is present in the database, but has a newer timestamp than the imported package, reimport operation is triggered - If an entry is found in the database and its source resource cannot be found, delete operation is triggered
- relativePath
- Path which to scan, relative to the source resource folder. If empty, entire source resource folder will be checked.
BlockUntilWorkerIdle
Blocks the calling thread until the worker has completed all operations.
IsImportInProgress
Checks is an import operation currently in progress for the specified source resource.
- sourceResourcePath
- Absolute path to the source resource that is potentially being imported.
Returns: True if import is in progress, false otherwise.
IsImportInProgress
Returns true if there is any import operation in progress.
GetActiveWorkerOperationCount
Returns number of operations that are currently in progress.
SaveLibrary
Saves all the project library data so it may be restored later, at the default save location in the project folder.
LoadLibrary
Loads previously saved project library data from the default save location in the project folder.
Nothing is loaded if it doesn't exist. This must be called before using the project library.
- projectFolder
- Project folder in which to initialize the library.
UnloadLibrary
Clears all library data.
GetProjectFolder
Returns the project folder that the library was initialized with during LoadLibrary call.
Returned path is absolute.
GetImportedResourceFolder
Returns the root folder in which all imported resources are stored in.
Returned path is absolute.
GetSourceResourceFolder
Returns the root folder from which source resources are stored.
Resources in this folder will be automatically imported and kept in sync with their counterparts in the imported resource folder.
CreateOperationContext
Creates context used for running project library operations from the currently loaded library.
GetDatabase
Returns the database that can be used for searching and manipulating library entries directly.
staticInstance
Returns a reference to the module instance.
Module has to have been started up first otherwise an exception will be thrown.
staticInstancePtr
Returns a pointer to the module instance.
Module has to have been started up first otherwise an exception will be thrown.
staticShutDown
Shuts down this module and frees any resources it is using.
staticIsStarted
Query if the module has been started.
Fields
Protected
Methods
~Module<T>
OnStartUp
Override if you want your module to be notified once it has been constructed and started.
OnShutDown
Override if you want your module to be notified just before it is deleted.
staticInstanceInternal
Returns a singleton instance of this module.
Private
Methods
NotifyEntryAdded
Notifies the event listeners that an entry was added to the library.
- relativePath
- Path provided is relative to the project library imported resources folder.
NotifyEntryRemoved
Notifies the event listeners that an entry was removed from the library.
- relativePath
- Path provided is relative to the project library imported resources folder.
NotifyEntryUpdated
Notifies the event listeners that an entry in the library was updated.
- relativePath
- Path provided is relative to the project library imported resources folder.
DoOnOperationFinished
Callback triggered when a worker has finished executing an operation.
Always called on the main thread.
RegisterInProgressImportOperation
Registers a new in-progress import operation.
- operationId
- ID of the operation, as returned by the worker.
- operation
- Import operation being executed.
GetResourceMetaData
Attempts to retrieve the project library resource meta-data for a resource with the specified ID.