# IsForeignAsset

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

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.3/script-reference/unityeditor.md)
* **Assembly:** UnityEditor

## IsForeignAsset(Object)

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

```csharp
public static bool IsForeignAsset(Object obj)
```

### Parameters

**** (\[Object]\(/engine/6000.3/script-reference/unityengine/object)): The object of the asset.

### Returns

| Type                                                          | Description                                                        |
| ------------------------------------------------------------- | ------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns true if the asset is a foreign asset, and false otherwise. |

### Remarks

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 importers reference](/engine/6000.3/manual/assets-and-media/asset-types/assets-supported-types.md), 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](/engine/6000.3/script-reference/unityeditor/assetdatabase/isnativeasset.md).

### Examples

```csharp
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);
        }
    }
}
```

## IsForeignAsset(EntityId)

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

```csharp
public static bool IsForeignAsset(EntityId entityId)
```

### Parameters

**** (\[EntityId]\(/engine/6000.3/script-reference/unityengine/entityid)): The EntityID of the asset.

### Returns

| Type                                                          | Description                                                        |
| ------------------------------------------------------------- | ------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns true if the asset is a foreign asset, and false otherwise. |

### Remarks

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 importers reference](/engine/6000.3/manual/assets-and-media/asset-types/assets-supported-types.md), 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](/engine/6000.3/script-reference/unityeditor/assetdatabase/isnativeasset.md).

### Examples

```csharp
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);
        }
    }
}
```

## IsForeignAsset(int)

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

> **Warning:**
>
> **Deprecated.** Please use IsForeignAsset(EntityId) with the EntityId type instead.

```csharp
public static bool IsForeignAsset(int instanceID)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The InstanceID of the asset.

### Returns

| Type                                                          | Description                                                        |
| ------------------------------------------------------------- | ------------------------------------------------------------------ |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | Returns true if the asset is a foreign asset, and false otherwise. |

### Remarks

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 importers reference](/engine/6000.3/manual/assets-and-media/asset-types/assets-supported-types.md), 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](/engine/6000.3/script-reference/unityeditor/assetdatabase/isnativeasset.md).

### Examples

```csharp
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);
        }
    }
}
```
