文档

Unity Engine

Unity Engine

GetScriptableObjectsWithMissingScriptCount(string)

Checks how many unloadable ScriptableObject instances are present in the specified asset.
阅读时间1 分钟最后更新于 1 个月前

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule
public static int GetScriptableObjectsWithMissingScriptCount(string assetPath)

Parameters

assetPath

The path to the asset file to check.

Returns

Type

Description

intThe number of ScriptableObject instances in the file which are missing their associated scripts.

Remarks

If you delete the script which defines a type of ScriptableObject, all instances of that ScriptableObject in your assets become unloadable. This also happens if you move or rename the script outside of Unity without also moving or renaming the script's .meta file accordingly. This method allows you to check whether an asset contains any such unloadable ScriptableObject instances due to missing scripts. You can remove unloadable ScriptableObject instances from your assets by using AssetDatabase.RemoveScriptableObjectsWithMissingScript.
Note: This function can only be used with native asset files. If you pass a non-native asset file, it will throw an exception.