Show / Hide Table of Contents

Class AssetDatabase

Inheritance
Object
AssetDatabase
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: UnityEditor
Assembly: UnityEditor.dll
Syntax
public sealed class AssetDatabase

Methods

AddObjectToAsset(Object, String)

Declaration
public static void AddObjectToAsset(Object objectToAdd, string path)
Parameters
Type Name Description
Object objectToAdd
String path
| Improve this Doc View Source

AddObjectToAsset(Object, Object)

Declaration
public static void AddObjectToAsset(Object objectToAdd, Object assetObject)
Parameters
Type Name Description
Object objectToAdd
Object assetObject

AssetPathToGUID(String)

Declaration
public static string AssetPathToGUID(string path)
Parameters
Type Name Description
String path
Returns
Type Description
String

ClearLabels(Object)

Declaration
public static void ClearLabels(Object obj)
Parameters
Type Name Description
Object obj

Contains(Int32)

Declaration
public static bool Contains(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
Boolean
| Improve this Doc View Source

Contains(Object)

Declaration
public static bool Contains(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean

CopyAsset(String, String)

Declaration
public static bool CopyAsset(string path, string newPath)
Parameters
Type Name Description
String path
String newPath
Returns
Type Description
Boolean

CreateAsset(Object, String)

Declaration
public static void CreateAsset(Object asset, string path)
Parameters
Type Name Description
Object asset
String path

CreateFolder(String, String)

Declaration
public static string CreateFolder(string parentFolder, string newFolderName)
Parameters
Type Name Description
String parentFolder
String newFolderName
Returns
Type Description
String

DeleteAsset(String)

Declaration
public static bool DeleteAsset(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Boolean
| Improve this Doc View Source

ExportPackage(String, String)

Declaration
public static void ExportPackage(string assetPathName, string fileName)
Parameters
Type Name Description
String assetPathName
String fileName
| Improve this Doc View Source

ExportPackage(String, String, ExportPackageOptions)

Declaration
public static void ExportPackage(string assetPathName, string fileName, ExportPackageOptions flags)
Parameters
Type Name Description
String assetPathName
String fileName
ExportPackageOptions flags
| Improve this Doc View Source

ExportPackage(String[], String)

Declaration
[ExcludeFromDocs]
public static void ExportPackage(string[] assetPathNames, string fileName)
Parameters
Type Name Description
String[] assetPathNames
String fileName

ExportPackage(String[], String, ExportPackageOptions)

Declaration
public static void ExportPackage(string[] assetPathNames, string fileName, [DefaultValue("ExportPackageOptions.Default")] ExportPackageOptions flags)
Parameters
Type Name Description
String[] assetPathNames
String fileName
ExportPackageOptions flags

ExtractAsset(Object, String)

Declaration
public static string ExtractAsset(Object asset, string newPath)
Parameters
Type Name Description
Object asset
String newPath
Returns
Type Description
String
| Improve this Doc View Source

FindAssets(String)

Declaration
public static string[] FindAssets(string filter)
Parameters
Type Name Description
String filter
Returns
Type Description
String[]
| Improve this Doc View Source

FindAssets(String, String[])

Declaration
public static string[] FindAssets(string filter, string[] searchInFolders)
Parameters
Type Name Description
String filter
String[] searchInFolders
Returns
Type Description
String[]
| Improve this Doc View Source

ForceReserializeAssets()

Declaration
public static void ForceReserializeAssets()
| Improve this Doc View Source

ForceReserializeAssets(IEnumerable<String>, ForceReserializeAssetsOptions)

Declaration
public static void ForceReserializeAssets(IEnumerable<string> assetPaths, ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata)
Parameters
Type Name Description
IEnumerable<String> assetPaths
ForceReserializeAssetsOptions options

GenerateUniqueAssetPath(String)

Declaration
public static string GenerateUniqueAssetPath(string path)
Parameters
Type Name Description
String path
Returns
Type Description
String

GetAllAssetBundleNames()

Declaration
public static string[] GetAllAssetBundleNames()
Returns
Type Description
String[]

GetAllAssetPaths()

Declaration
public static string[] GetAllAssetPaths()
Returns
Type Description
String[]

GetAssetBundleDependencies(String, Boolean)

Declaration
public static string[] GetAssetBundleDependencies(string assetBundleName, bool recursive)
Parameters
Type Name Description
String assetBundleName
Boolean recursive
Returns
Type Description
String[]
| Improve this Doc View Source

GetAssetBundleNames()

Declaration
[Obsolete("Method GetAssetBundleNames has been deprecated. Use GetAllAssetBundleNames instead.")]
public string[] GetAssetBundleNames()
Returns
Type Description
String[]
| Improve this Doc View Source

GetAssetDependencyHash(String)

Declaration
public static Hash128 GetAssetDependencyHash(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Hash128

GetAssetOrScenePath(Object)

Declaration
public static string GetAssetOrScenePath(Object assetObject)
Parameters
Type Name Description
Object assetObject
Returns
Type Description
String
| Improve this Doc View Source

GetAssetPath(Int32)

Declaration
public static string GetAssetPath(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
String

GetAssetPath(Object)

Declaration
public static string GetAssetPath(Object assetObject)
Parameters
Type Name Description
Object assetObject
Returns
Type Description
String

GetAssetPathFromTextMetaFilePath(String)

Declaration
public static string GetAssetPathFromTextMetaFilePath(string path)
Parameters
Type Name Description
String path
Returns
Type Description
String

GetAssetPathsFromAssetBundle(String)

Declaration
public static string[] GetAssetPathsFromAssetBundle(string assetBundleName)
Parameters
Type Name Description
String assetBundleName
Returns
Type Description
String[]

GetAssetPathsFromAssetBundleAndAssetName(String, String)

Declaration
public static string[] GetAssetPathsFromAssetBundleAndAssetName(string assetBundleName, string assetName)
Parameters
Type Name Description
String assetBundleName
String assetName
Returns
Type Description
String[]

GetBuiltinExtraResource(Type, String)

Declaration
[TypeInferenceRule(TypeInferenceRules.TypeReferencedByFirstArgument)]
public static Object GetBuiltinExtraResource(Type type, string path)
Parameters
Type Name Description
Type type
String path
Returns
Type Description
Object
| Improve this Doc View Source

GetBuiltinExtraResource<T>(String)

Declaration
public static T GetBuiltinExtraResource<T>(string path)
    where T : Object
Parameters
Type Name Description
String path
Returns
Type Description
T
Type Parameters
Name Description
T

GetCachedIcon(String)

Declaration
public static Texture GetCachedIcon(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Texture

GetCurrentCacheServerIp()

Declaration
public static string GetCurrentCacheServerIp()
Returns
Type Description
String
| Improve this Doc View Source

GetDependencies(String)

Declaration
public static string[] GetDependencies(string pathName)
Parameters
Type Name Description
String pathName
Returns
Type Description
String[]
| Improve this Doc View Source

GetDependencies(String, Boolean)

Declaration
public static string[] GetDependencies(string pathName, bool recursive)
Parameters
Type Name Description
String pathName
Boolean recursive
Returns
Type Description
String[]
| Improve this Doc View Source

GetDependencies(String[])

Declaration
public static string[] GetDependencies(string[] pathNames)
Parameters
Type Name Description
String[] pathNames
Returns
Type Description
String[]

GetDependencies(String[], Boolean)

Declaration
public static string[] GetDependencies(string[] pathNames, bool recursive)
Parameters
Type Name Description
String[] pathNames
Boolean recursive
Returns
Type Description
String[]

GetImplicitAssetBundleName(String)

Declaration
public static string GetImplicitAssetBundleName(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
String

GetImplicitAssetBundleVariantName(String)

Declaration
public static string GetImplicitAssetBundleVariantName(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
String

GetLabels(Object)

Declaration
public static string[] GetLabels(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
String[]

GetMainAssetTypeAtPath(String)

Declaration
public static Type GetMainAssetTypeAtPath(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
Type

GetSubFolders(String)

Declaration
public static string[] GetSubFolders(string path)
Parameters
Type Name Description
String path
Returns
Type Description
String[]
| Improve this Doc View Source

GetTextMetaDataPathFromAssetPath(String)

Declaration
[Obsolete("GetTextMetaDataPathFromAssetPath has been renamed to GetTextMetaFilePathFromAssetPath (UnityUpgradable) -> GetTextMetaFilePathFromAssetPath(*)")]
public static string GetTextMetaDataPathFromAssetPath(string path)
Parameters
Type Name Description
String path
Returns
Type Description
String

GetTextMetaFilePathFromAssetPath(String)

Declaration
public static string GetTextMetaFilePathFromAssetPath(string path)
Parameters
Type Name Description
String path
Returns
Type Description
String

GetUnusedAssetBundleNames()

Declaration
public static string[] GetUnusedAssetBundleNames()
Returns
Type Description
String[]

GUIDToAssetPath(String)

Declaration
public static string GUIDToAssetPath(string guid)
Parameters
Type Name Description
String guid
Returns
Type Description
String
| Improve this Doc View Source

ImportAsset(String)

Declaration
[ExcludeFromDocs]
public static void ImportAsset(string path)
Parameters
Type Name Description
String path

ImportAsset(String, ImportAssetOptions)

Declaration
public static void ImportAsset(string path, [DefaultValue("ImportAssetOptions.Default")] ImportAssetOptions options)
Parameters
Type Name Description
String path
ImportAssetOptions options
| Improve this Doc View Source

ImportPackage(String, Boolean)

Declaration
public static void ImportPackage(string packagePath, bool interactive)
Parameters
Type Name Description
String packagePath
Boolean interactive

IsForeignAsset(Int32)

Declaration
public static bool IsForeignAsset(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
Boolean
| Improve this Doc View Source

IsForeignAsset(Object)

Declaration
public static bool IsForeignAsset(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean

IsMainAsset(Int32)

Declaration
public static bool IsMainAsset(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
Boolean
| Improve this Doc View Source

IsMainAsset(Object)

Declaration
public static bool IsMainAsset(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean

IsMainAssetAtPathLoaded(String)

Declaration
public static bool IsMainAssetAtPathLoaded(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
Boolean
| Improve this Doc View Source

IsMetaFileOpenForEdit(Object)

Declaration
[Obsolete("AssetDatabase.IsMetaFileOpenForEdit without StatusQueryOptions has been deprecated. Use the version with StatusQueryOptions instead. This will always request the cached status (StatusQueryOptions.UseCachedIfPossible)")]
public static bool IsMetaFileOpenForEdit(Object assetObject)
Parameters
Type Name Description
Object assetObject
Returns
Type Description
Boolean
| Improve this Doc View Source

IsMetaFileOpenForEdit(Object, out String)

Declaration
[Obsolete("AssetDatabase.IsMetaFileOpenForEdit without StatusQueryOptions has been deprecated. Use the version with StatusQueryOptions instead. This will always request the cached status (StatusQueryOptions.UseCachedIfPossible)")]
public static bool IsMetaFileOpenForEdit(Object assetObject, out string message)
Parameters
Type Name Description
Object assetObject
String message
Returns
Type Description
Boolean
| Improve this Doc View Source

IsMetaFileOpenForEdit(Object, out String, StatusQueryOptions)

Declaration
public static bool IsMetaFileOpenForEdit(Object assetObject, out string message, StatusQueryOptions statusOptions)
Parameters
Type Name Description
Object assetObject
String message
StatusQueryOptions statusOptions
Returns
Type Description
Boolean
| Improve this Doc View Source

IsMetaFileOpenForEdit(Object, StatusQueryOptions)

Declaration
public static bool IsMetaFileOpenForEdit(Object assetObject, StatusQueryOptions statusOptions)
Parameters
Type Name Description
Object assetObject
StatusQueryOptions statusOptions
Returns
Type Description
Boolean

IsNativeAsset(Int32)

Declaration
public static bool IsNativeAsset(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
Boolean
| Improve this Doc View Source

IsNativeAsset(Object)

Declaration
public static bool IsNativeAsset(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(String)

Declaration
[Obsolete("AssetDatabase.IsOpenForEdit without StatusQueryOptions has been deprecated. Use the version with StatusQueryOptions instead. This will always request the cached status (StatusQueryOptions.UseCachedIfPossible)")]
public static bool IsOpenForEdit(string assetOrMetaFilePath)
Parameters
Type Name Description
String assetOrMetaFilePath
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(String, out String)

Declaration
[Obsolete("AssetDatabase.IsOpenForEdit without StatusQueryOptions has been deprecated. Use the version with StatusQueryOptions instead. This will always request the cached status (StatusQueryOptions.UseCachedIfPossible)")]
public static bool IsOpenForEdit(string assetOrMetaFilePath, out string message)
Parameters
Type Name Description
String assetOrMetaFilePath
String message
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(String, out String, StatusQueryOptions)

Declaration
public static bool IsOpenForEdit(string assetOrMetaFilePath, out string message, StatusQueryOptions statusOptions)
Parameters
Type Name Description
String assetOrMetaFilePath
String message
StatusQueryOptions statusOptions
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(String, StatusQueryOptions)

Declaration
public static bool IsOpenForEdit(string assetOrMetaFilePath, StatusQueryOptions StatusQueryOptions)
Parameters
Type Name Description
String assetOrMetaFilePath
StatusQueryOptions StatusQueryOptions
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(Object)

Declaration
[Obsolete("AssetDatabase.IsOpenForEdit without StatusQueryOptions has been deprecated. Use the version with StatusQueryOptions instead. This will always request the cached status (StatusQueryOptions.UseCachedIfPossible)")]
public static bool IsOpenForEdit(Object assetObject)
Parameters
Type Name Description
Object assetObject
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(Object, out String)

Declaration
[Obsolete("AssetDatabase.IsOpenForEdit without StatusQueryOptions has been deprecated. Use the version with StatusQueryOptions instead. This will always request the cached status (StatusQueryOptions.UseCachedIfPossible)")]
public static bool IsOpenForEdit(Object assetObject, out string message)
Parameters
Type Name Description
Object assetObject
String message
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(Object, out String, StatusQueryOptions)

Declaration
public static bool IsOpenForEdit(Object assetObject, out string message, StatusQueryOptions statusOptions)
Parameters
Type Name Description
Object assetObject
String message
StatusQueryOptions statusOptions
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOpenForEdit(Object, StatusQueryOptions)

Declaration
public static bool IsOpenForEdit(Object assetObject, StatusQueryOptions StatusQueryOptions)
Parameters
Type Name Description
Object assetObject
StatusQueryOptions StatusQueryOptions
Returns
Type Description
Boolean

IsSubAsset(Int32)

Declaration
public static bool IsSubAsset(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
Boolean
| Improve this Doc View Source

IsSubAsset(Object)

Declaration
public static bool IsSubAsset(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean

IsValidFolder(String)

Declaration
public static bool IsValidFolder(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Boolean

LoadAllAssetRepresentationsAtPath(String)

Declaration
public static Object[] LoadAllAssetRepresentationsAtPath(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
Object[]

LoadAllAssetsAtPath(String)

Declaration
public static Object[] LoadAllAssetsAtPath(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
Object[]

LoadAssetAtPath(String, Type)

Declaration
[TypeInferenceRule(TypeInferenceRules.TypeReferencedBySecondArgument)]
public static Object LoadAssetAtPath(string assetPath, Type type)
Parameters
Type Name Description
String assetPath
Type type
Returns
Type Description
Object
| Improve this Doc View Source

LoadAssetAtPath<T>(String)

Declaration
public static T LoadAssetAtPath<T>(string assetPath)
    where T : Object
Parameters
Type Name Description
String assetPath
Returns
Type Description
T
Type Parameters
Name Description
T

LoadMainAssetAtPath(String)

Declaration
public static Object LoadMainAssetAtPath(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
Object

MoveAsset(String, String)

Declaration
public static string MoveAsset(string oldPath, string newPath)
Parameters
Type Name Description
String oldPath
String newPath
Returns
Type Description
String

MoveAssetToTrash(String)

Declaration
public static bool MoveAssetToTrash(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Boolean
| Improve this Doc View Source

OpenAsset(Int32)

Declaration
[ExcludeFromDocs]
public static bool OpenAsset(int instanceID)
Parameters
Type Name Description
Int32 instanceID
Returns
Type Description
Boolean

OpenAsset(Int32, Int32)

Declaration
public static bool OpenAsset(int instanceID, [DefaultValue("-1")] int lineNumber)
Parameters
Type Name Description
Int32 instanceID
Int32 lineNumber
Returns
Type Description
Boolean
| Improve this Doc View Source

OpenAsset(Object)

Declaration
[ExcludeFromDocs]
public static bool OpenAsset(Object target)
Parameters
Type Name Description
Object target
Returns
Type Description
Boolean
| Improve this Doc View Source

OpenAsset(Object, Int32)

Declaration
public static bool OpenAsset(Object target, [DefaultValue("-1")] int lineNumber)
Parameters
Type Name Description
Object target
Int32 lineNumber
Returns
Type Description
Boolean
| Improve this Doc View Source

OpenAsset(Object[])

Declaration
public static bool OpenAsset(Object[] objects)
Parameters
Type Name Description
Object[] objects
Returns
Type Description
Boolean
| Improve this Doc View Source

Refresh()

Declaration
[ExcludeFromDocs]
public static void Refresh()

Refresh(ImportAssetOptions)

Declaration
public static void Refresh([DefaultValue("ImportAssetOptions.Default")] ImportAssetOptions options)
Parameters
Type Name Description
ImportAssetOptions options
| Improve this Doc View Source

RefreshDelayed()

Declaration
[Obsolete("Please use AssetDatabase.Refresh instead", true)]
public static void RefreshDelayed()
| Improve this Doc View Source

RefreshDelayed(ImportAssetOptions)

Declaration
[Obsolete("Please use AssetDatabase.Refresh instead", true)]
public static void RefreshDelayed(ImportAssetOptions options)
Parameters
Type Name Description
ImportAssetOptions options

ReleaseCachedFileHandles()

Declaration
public static void ReleaseCachedFileHandles()

RemoveAssetBundleName(String, Boolean)

Declaration
public static bool RemoveAssetBundleName(string assetBundleName, bool forceRemove)
Parameters
Type Name Description
String assetBundleName
Boolean forceRemove
Returns
Type Description
Boolean

RemoveObjectFromAsset(Object)

Declaration
public static void RemoveObjectFromAsset(Object objectToRemove)
Parameters
Type Name Description
Object objectToRemove

RemoveUnusedAssetBundleNames()

Declaration
public static void RemoveUnusedAssetBundleNames()

RenameAsset(String, String)

Declaration
public static string RenameAsset(string pathName, string newName)
Parameters
Type Name Description
String pathName
String newName
Returns
Type Description
String

SaveAssets()

Declaration
public static void SaveAssets()

SetLabels(Object, String[])

Declaration
public static void SetLabels(Object obj, string[] labels)
Parameters
Type Name Description
Object obj
String[] labels

SetMainObject(Object, String)

Declaration
public static void SetMainObject(Object mainObject, string assetPath)
Parameters
Type Name Description
Object mainObject
String assetPath

StartAssetEditing()

Declaration
public static void StartAssetEditing()

StopAssetEditing()

Declaration
public static void StopAssetEditing()
| Improve this Doc View Source

TryGetGUIDAndLocalFileIdentifier(Int32, out String, out Int64)

Declaration
public static bool TryGetGUIDAndLocalFileIdentifier(int instanceID, out string guid, out long localId)
Parameters
Type Name Description
Int32 instanceID
String guid
Int64 localId
Returns
Type Description
Boolean
| Improve this Doc View Source

TryGetGUIDAndLocalFileIdentifier(Object, out String, out Int64)

Declaration
public static bool TryGetGUIDAndLocalFileIdentifier(Object obj, out string guid, out long localId)
Parameters
Type Name Description
Object obj
String guid
Int64 localId
Returns
Type Description
Boolean

ValidateMoveAsset(String, String)

Declaration
public static string ValidateMoveAsset(string oldPath, string newPath)
Parameters
Type Name Description
String oldPath
String newPath
Returns
Type Description
String

WriteImportSettingsIfDirty(String)

Declaration
public static bool WriteImportSettingsIfDirty(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Boolean

Events

| Improve this Doc View Source

importPackageCancelled

Declaration
public static event AssetDatabase.ImportPackageCallback importPackageCancelled
Event Type
Type Description
AssetDatabase.ImportPackageCallback
| Improve this Doc View Source

importPackageCompleted

Declaration
public static event AssetDatabase.ImportPackageCallback importPackageCompleted
Event Type
Type Description
AssetDatabase.ImportPackageCallback
| Improve this Doc View Source

importPackageFailed

Declaration
public static event AssetDatabase.ImportPackageFailedCallback importPackageFailed
Event Type
Type Description
AssetDatabase.ImportPackageFailedCallback
| Improve this Doc View Source

importPackageStarted

Declaration
public static event AssetDatabase.ImportPackageCallback importPackageStarted
Event Type
Type Description
AssetDatabase.ImportPackageCallback

Extension Methods

MustExtensions.MustBeEqual<T>(T, T)
MustExtensions.MustBeEqual<T>(T, T, String)
MustExtensions.MustNotBeEqual<T>(T, T)
MustExtensions.MustNotBeEqual<T>(T, T, String)
MustExtensions.MustBeNull<T>(T)
MustExtensions.MustBeNull<T>(T, String)
MustExtensions.MustNotBeNull<T>(T)
MustExtensions.MustNotBeNull<T>(T, String)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX