# IsForeignAsset

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

## Definition

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

## IsForeignAsset(Object)

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

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

### Parameters

**** (\[Object]\(/engine/7000.0/script-reference/unityengine/object)): The asset object to check.

### Returns

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

### Remarks

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](/engine/7000.0/manual/assets-and-media/asset-types/assets-supported-types.md) and [AssetDatabase.IsNativeAsset](/engine/7000.0/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)

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

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

### Parameters

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

### Returns

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

### Remarks

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](/engine/7000.0/manual/assets-and-media/asset-types/assets-supported-types.md) and [AssetDatabase.IsNativeAsset](/engine/7000.0/script-reference/unityeditor/assetdatabase/isnativeasset.md).

## IsForeignAsset(int)

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

> **Warning:**
>
> **Removed.** 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 instance ID of the asset to check.

### Returns

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

### Remarks

This overload is obsolete. Use the overload that takes an [EntityId](/engine/7000.0/script-reference/unityengine/entityid.md) instead.
