# Get Prefab Asset From Gameobject in Edit Mode

I want to get a prefab asset (that resides in Project Window) and assign it to a field like the one you get when you manually drag the prefab asset from Project Window to GameObject field:

But when I try to do the same thing in code (and in Edit Mode) with this function:

GameObject prefab_instance = PrefabUtility.GetNearestPrefabInstanceRoot(gameobj) as GameObject;


I get a prefab instance but not a prefab asset:

How do I get a reference to prefab asset from the gameobject that was created from it?

string path = PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(gameobj);