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

AssetDatabase.IsForeignAsset

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

Parameters

Parameter Description
obj The asset object to check.

Returns

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

Description

Checks whether an asset object is a foreign asset, created outside Unity.

A foreign asset is an asset that wasn't created in Unity, for example a .png texture file. During import, Unity creates a serialized representation of a foreign asset in the Library folder of the project. This happens when you first add the asset, when it changes outside Unity, and when you change its import settings. An asset that Unity creates, such as a material, is a native asset. For more information, refer to Native asset importers reference and AssetDatabase.IsNativeAsset.

using UnityEditor;
using UnityEngine;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Find Foreign Assets")] static void FindForeignAssets() { //Find all foreign assets foreach (var guid in AssetDatabase.FindAssets("",new []{"Assets"})) { var path = AssetDatabase.GUIDToAssetPath(guid); var asset = AssetDatabase.LoadMainAssetAtPath(path); var assetIsForeign = AssetDatabase.IsForeignAsset(asset); if(assetIsForeign) Debug.Log(asset); } } }

Declaration

public static bool IsForeignAsset(EntityId entityId);

Parameters

Parameter Description
entityId The EntityId of the asset to check.

Returns

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

Description

Checks whether the asset with the specified EntityId is a foreign asset, created outside Unity.

A foreign asset is an asset that wasn't created in Unity, for example a .png texture file. During import, Unity creates a serialized representation of a foreign asset in the Library folder of the project. This happens when you first add the asset, when it changes outside Unity, and when you change its import settings. An asset that Unity creates, such as a material, is a native asset. For more information, refer to Native asset importers reference and AssetDatabase.IsNativeAsset.


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

Declaration

public static bool IsForeignAsset(int instanceID);

Parameters

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

Returns

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

Description

Checks whether the asset with the specified instance ID is a foreign asset, created outside Unity.

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