AssetDatabase 资源数据库
An Interface for accessing assets and performing operations on assets.
AssetDatabase是一个对资源进行读写和各种操作的接口。
Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.
注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。
Class Functions类函数
- ContainsIs object an asset? // 资源中是否存在该对象?
- CreateFolderCreate a new folder. // 创建一个新的文件夹。
- IsMainAssetIs asset a main asset in the project window?
该资源在Project窗口中是不是主资源? - GenerateUniqueAssetPathCreates a new unique path for an asset.
给一个资源创建一个新的唯一路径。 - StartAssetEditingBegin Asset importing. This lets you group several asset imports together into one larger import.
开始资源导入。它可以让你把多个资源导入组合成一个更大的导入。 - StopAssetEditingStop Asset importing. This lets you group several asset imports together into one larger import.
停止资源导入。这可以让你把多个资源导入组合成一个更大的导入。 - ValidateMoveAssetChecks if an asset file can be moved from one folder to another. (Without actually moving the file)
检查一个资源文件是否可以从一个文件夹移动到另外一个。(并不是真的移动这个文件) - MoveAssetMove an asset file from one folder to another.
将一个资源文件从一个文件夹移动到另外一个文件夹。 - RenameAssetRename an asset file. // 重命名资源文件。
- MoveAssetToTrashMoves the asset at path to the trash.
将指定路径的资源移动到回收站。 - DeleteAssetDeletes the asset file at path.
删除指定路径的资源文件。 - ImportAssetImport asset at path.
导入指定路径的资源。 - CopyAssetDuplicates the asset at path and stores it at newPath
复制指定路径的资源文件到一个新的路径。 - CreateAssetCreates a new asset at path.
在指定的路径新建资源。 - AddObjectToAssetAdds objectToAdd to an existing asset at path.
将objectToAdd这个对象添加到指定路径上的现有资源。 - GetAssetPathReturns the path name relative to the project folder where the asset is stored
返回相对于工程资源位置的路径名。 - GetTextMetaDataPathFromA...Gets the path to the text .meta file associasted with an asset
获取资源有关文本.meta文件的路径。 - LoadAssetAtPathReturns the first asset object of type type at given path assetPath.
返回在指定位置assetPath下第一个类型是type的资源对象。 - LoadMainAssetAtPathReturns the main asset object at assetPath.
返回指定路径assetPath下的主资源。 - LoadAllAssetRepresentations...Returns all asset representations at assetPath.
返回assetPath所在路径的所有资源说明。 - LoadAllAssetsAtPathReturns an array of all asset objects at assetPath.
返回指定路径assetPath下的所有资源对象数组。 - RefreshImport any changed assets.
重新导入有更新的资源。 - OpenAssetOpens the asset with associated application.
用关联的程序打开资源文件。 - AssetPathToGUIDGet the GUID for the asset at path
返回指定路径path下资源的GUID(全局唯一标识符)。 - GUIDToAssetPathTranslate a GUID to its current asset path
将GUID(全局唯一标识符)转换为对应的资源路径。 - SaveAssetsWrites all unsaved asset changes to disk.
将所有未保存的资源更改写入磁盘。 - GetCachedIconRetrieves an icon for the asset at the given asset path.
为指定路径的资源检索一个图标。 - CompleteLabelReturns all labels that match the given prefix.
返回符合给定前缀的所有标签。 - SetLabelsReplaces that list of labels on an asset.
替换资源的标签列表。 - GetLabelsReturns all labels attached to a given asset.
返回给定资源拥有的所有标签。 - ClearLabelsRemoves all labels attached to an asset.
移除资源上所有的标签。 - GetDependenciesGiven an asset pathName, returns the list of all assets it depends on.
已知资源pathName,返回与它有依赖关系的所有资源列表。 - ExportPackageExports the assets identified by assetPathNames to a unitypackage file in fileName.
导出assetPahtNames定义的资源到一个unitypackage里,并命名filename。 - ImportPackageImports package at packagePath into the current project.
将packagePath下的资源包导入到当前工程。