Loading...
Searching...
No Matches
localizeAsset.h File Reference
+ Include dependency graph for localizeAsset.h:

Go to the source code of this file.

Functions

USDUTILS_API bool UsdUtilsLocalizeAsset (const SdfAssetPath &assetPath, const std::string &localizationDirectory, bool editLayersInPlace=false, std::function< UsdUtilsProcessingFunc > processingFunc=std::function< UsdUtilsProcessingFunc >())
 Creates a localized version of the asset identified by assetPath and all of its external dependencies in the directory specified by localizationDirectory.
 

Function Documentation

◆ UsdUtilsLocalizeAsset()

USDUTILS_API bool UsdUtilsLocalizeAsset ( const SdfAssetPath assetPath,
const std::string &  localizationDirectory,
bool  editLayersInPlace = false,
std::function< UsdUtilsProcessingFunc processingFunc = std::function< UsdUtilsProcessingFunc >() 
)

Creates a localized version of the asset identified by assetPath and all of its external dependencies in the directory specified by localizationDirectory.

Any anonymous layers that are encountered during dependency discovery will be serialized into the resulting package. Due to localization, the packaged layers might be modified to have different asset paths.

The editLayersInPlace parameter controls the strategy used for managing changes to layers (including the root layer and all transitive layer dependencies) that occur during the package creation process. When editLayersInPlace is false, a temporary, anonymous copy of each modified layer is created and written into the package. This has the advantage of leaving source layers untouched at the expense of creating a copy of each modified layer in memory for the duration of this function.

When editLayersInPlace is set to true, layers are modified in-place and not reverted or persisted once the package has been created. In this case, there is no overhead of creating copies of each modified layer. If you have UsdStages open during the function call that reference the layers being modified, you may receive warnings or composition errors. While these errors will not affect the resulting package adversely, it is strongly recommended that this function is run in isolation after any source UsdStages have been closed.

If a function is provided for the processingFunc parameter, it will be invoked on every asset path that is discovered during localization. This allows you to inject your own logic into the process. Refer to UsdUtilsDependencyInfo for general information on user processing functions. If an asset path is ignored in the processing function, it will be removed from the layer and excluded from the localized package. Paths that are modified will have their updated value written back into the localized layer. Paths that are added to the dependencies array during processing will be included in the resulting localized asset.

Returns true if the package was created successfully.

Note
Clients of this function must take care of configuring the asset resolver context before invoking the function. To create a default resolver context, use CreateDefaultContextForAsset() with the asset path.
If the given asset has a dependency on a directory (i.e. an external reference to a directory path), the dependency is ignored and the contents of the directory are not included in the created package.