Version: Unity 6.5 Alpha (6000.5)
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);

Declaration

public static bool IsForeignAsset(EntityId entityId);
Obsolete Please use IsForeignAsset(EntityId) with the EntityId type instead.

Declaration

public static bool IsForeignAsset(int instanceID);

Parameters

Parameter Description
obj The object of the asset.
entityId The EntityID of the asset.
instanceID The InstanceID of the asset.

Returns

bool Returns true if the asset is a foreign asset, and false otherwise.

Description

Determines whether a given asset is an external asset, also known as a foreign asset.

A foreign asset is any asset that isn't created within Unity, for example a .png texture file. An asset created in Unity is a native asset, for example a material or a prefab.

Unity creates a serialized representation of foreign assets in the Project's Library folder during import. This happens when the asset is first added, when it's updated externally, or when you modify its import settings in the Editor.

Additional resources: 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); } } }