Luna::Asset::new_asset

R< asset_t > new_asset(const Path &path, const Name &type, bool save_meta_to_file=true)

Creates a new asset by specifying the path and type of the asset.

This function performs the following options to create a new asset:1. Checks whether one asset with the specified path exists, and returns the existing asset if any.

  1. Call get_asset with GUID (0, 0) to generate a new asset entry.

  2. Call register_asset to register the asset with the specified type.

  3. Sets the path of the asset.

  4. If save_meta_to_file is true, saves asset metadata.

  5. Returns the created asset.

Parameters

  • in path

    The path to place the new created asset. If the asset with the specified path is already registered, this call does nothing and returnes the registered asset directly.

This parameter can be empty (Path()), in such case, the asset is created as one dynamic asset that cannot be saved to files. If this is empty, path duplication check will be skipped.

Parameters

  • in type

    The type of the asset.

  • in save_meta_to_file

    Whether to create one metadata file for the new asset and saves metadta to the file.

Return value

Returns the asset handle of the new created asset.

Valid Usage

  • If save_meta_to_file is true, path must not be empty.