# GetCorrespondingObjectFromSourceAtPath<TObject>(TObject, string)

> Retrieves the corresponding object of the given object from a given Prefab Asset path.

## Definition

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

## GetCorrespondingObjectFromSourceAtPath\<T>(T, string)

```csharp
public static TObject GetCorrespondingObjectFromSourceAtPath<TObject>(TObject componentOrGameObject, string assetPath) where TObject : Object
```

### Parameters

**** (T): The object to find the corresponding object from.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The asset path of the Prefab Asset to get the corresponding object from.

### Returns

| Type | Description                       |
| ---- | --------------------------------- |
| T    | The corresponding object or null. |

### Remarks

Use this method to find the corresponding asset the source was instantiated from, if but only if it is within the prefab asset at the specified path.

If you don't have the path to pass in, you can use [PrefabUtility.GetCorrespondingObjectFromSource](/engine/6000.0/script-reference/unityeditor/prefabutility/getcorrespondingobjectfromsource.md) instead.

This method returns null if the given object does not have a corresponding object within the prefab asset at the specified path.

For example, in the diagram shown below, prefab asset "A" contains a child nested prefab "B", which contains a child nested prefab "C".

![nested prefab instance example (GetCorrespondingObjectFromSourceAtPath\<TObject>(TObject, string))](/api/media?file=/engine/6000.0/media/images/nested-prefab-instance-example.png)

In this example scenario, when the GameObject "C (Instance)" is passed in as the source to this method, and "Assets/A.prefab" is passed as the path, this method returns the object "C (Nested Prefab)" from the prefab asset "A".

The example script below adds a menu item to the editor, which launches a simple wizard that allows you to test the results of this method.

```csharp
using UnityEditor;
using UnityEngine;
public class AssetSourceTestWizard : ScriptableWizard
{
    public GameObject instance;
    public string path;

    [MenuItem("Test/Asset Source Test Wizard")]
    static void CreateWizard()
    {
        ScriptableWizard.DisplayWizard<AssetSourceTestWizard>("Asset Source Test Wizard", "Do Test");
    }

    void OnWizardCreate()
    {
        var o1 = PrefabUtility.GetCorrespondingObjectFromSourceAtPath(instance, path);
        Debug.Log("Corresponding object from source: " + o1.name);
    }
}
```

See also: [PrefabUtility.GetCorrespondingObjectFromSource](/engine/6000.0/script-reference/unityeditor/prefabutility/getcorrespondingobjectfromsource.md), [PrefabUtility.GetOriginalSourceRootWhereGameObjectIsAdded](/engine/6000.0/script-reference/unityeditor/prefabutility/getoriginalsourcerootwheregameobjectisadded.md), [PrefabUtility.GetCorrespondingObjectFromOriginalSource](/engine/6000.0/script-reference/unityeditor/prefabutility/getcorrespondingobjectfromoriginalsource.md).
