static void MoveAssetToDirectory( Asset asset, string directory, bool overwrite )

robot_2Generated
code_blocksInput

Description

The MoveAssetToDirectory method is a static utility function provided by the Editor.EditorUtility class. It allows you to move an asset from its current location to a specified directory within the editor environment. This method is useful for organizing assets within your project structure.

Usage

To use the MoveAssetToDirectory method, you need to provide the following parameters:

  • asset: The asset you want to move. This should be an instance of Editor.Asset.
  • directory: The target directory path as a string where the asset should be moved.
  • overwrite: A bool indicating whether to overwrite an existing asset in the target directory if one exists with the same name.

Ensure that the directory path is valid and that you have the necessary permissions to move the asset.

Example

// Example usage of MoveAssetToDirectory
Editor.Asset myAsset = GetAsset(); // Assume GetAsset() returns a valid asset
string targetDirectory = "Assets/NewFolder";
bool shouldOverwrite = true;

Editor.EditorUtility.MoveAssetToDirectory(myAsset, targetDirectory, shouldOverwrite);