Google.VersionHandler.FileMetadata.RenameAsset C# (CSharp) Method

RenameAsset() public method

Rename the file associated with this data.
public RenameAsset ( string newFilename ) : bool
newFilename string New name of the file.
return bool
        public bool RenameAsset(string newFilename) {
            var filenameComponents = new FilenameComponents(newFilename);
            Debug.Assert(filenameComponents.directory ==
                         Path.GetDirectoryName(filename));
            // If the target file exists, delete it.
            if (AssetImporter.GetAtPath(newFilename) != null) {
                if (!AssetDatabase.MoveAssetToTrash(newFilename)) {
                    UnityEngine.Debug.LogError(
                        "Failed to move asset to trash: " + filename);
                    return false;
                }
            }
            string error = AssetDatabase.RenameAsset(
                filename, filenameComponents.basenameNoExtension);
            if (!String.IsNullOrEmpty(error)) {
                UnityEngine.Debug.LogError(
                    "Failed to rename asset " + filename + " to " +
                    newFilename + " (" + error + ")");
                return false;
            }
            AssetDatabase.ImportAsset(newFilename);
            filename = newFilename;
            UpdateAssetLabels();
            return true;
        }