Version: Unity 7.0 Alpha (7000.0)
LanguageEnglish
  • C#

AssetDatabase.IsNativeAsset

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 bool IsNativeAsset(Object obj);

Parameters

Parameter Description
obj The asset object to check.

Returns

bool True if the asset is a native asset. Otherwise, false.

Description

Checks whether an asset object is a native asset, created by Unity.

A native asset is a file that Unity's serialization system creates directly, for example a .mat material file. Scenes, prefabs, and assembly definitions aren't native assets. An asset created outside Unity, such as a .png texture file, is a foreign asset. For more information, refer to Native asset importers reference and AssetDatabase.IsForeignAsset.

using UnityEditor;
using UnityEngine;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/List All Native Files")] static void ListNativeFiles() { //List all native assets in the project foreach (var guid in AssetDatabase.FindAssets("", new []{"Assets"})) { var path = AssetDatabase.GUIDToAssetPath(guid); var asset = AssetDatabase.LoadMainAssetAtPath(path); if(AssetDatabase.IsNativeAsset(asset)) Debug.Log(asset); } } }

Declaration

public static bool IsNativeAsset(EntityId entityId);

Parameters

Parameter Description
entityId The EntityId of the asset to check.

Returns

bool True if the asset is a native asset. Otherwise, false.

Description

Checks whether the asset with the specified EntityId is a native asset, created by Unity.

A native asset is a file that Unity's serialization system creates directly, for example a .mat material file. Scenes, prefabs, and assembly definitions aren't native assets. An asset created outside Unity, such as a .png texture file, is a foreign asset. For more information, refer to Native asset importers reference and AssetDatabase.IsForeignAsset.


Obsolete Please use IsNativeAsset(EntityId) with the EntityId type instead.

Declaration

public static bool IsNativeAsset(int instanceID);

Parameters

Parameter Description
instanceID The instance ID of the asset to check.

Returns

bool True if the asset is a native asset. Otherwise, false.

Description

Checks whether the asset with the specified instance ID is a native asset, created by Unity.

This overload is obsolete. Use the overload that takes an EntityId instead.

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