Version: 2023.2
LanguageEnglish
  • C#

AssetDatabase.GetScriptableObjectsWithMissingScriptCount

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public static int GetScriptableObjectsWithMissingScriptCount(string assetPath);

Parameters

assetPath The path to the asset file to check.

Returns

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

Description

Checks how many unloadable ScriptableObject instances are present in the specified asset.

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.

See Also: AssetDatabase.RemoveScriptableObjectsWithMissingScript, GameObjectUtility.GetMonoBehavioursWithMissingScriptCount.

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961