AssetDatabase.LoadAssetAtPath and Prefab Instances

Hello!

As you know AssetDatabase.LoadAssetAtPath only works in editor and allows to load assets which are not located in Resources folder.

My assets exactly are not located in Resources folder and I’m not allowed to re-locate them.
So I can not use Resources.Load. I have a self-made button in Editor which, using AssetDatabase.LoadAssetAtPath, loads prefabs into my scene.

I’m pretty happy with the result, but there is one flaw: GameObjects loaded with AssetDatabase.LoadAssetAtPath are not prefab instances. And, so, if I edit prefab, my GameObject in scene will not be updated.

If I drag-n-drop items from Project tab into the Editor window, such GameObjects are prefab instances, exactly what I need. But there’s too much of them to do it manually. I want the same result by code.

Is there a way to load assets into scene saving the Prefab Instance link?
Or is there a way to restore it post-factum?

Thank you for answer in advance.

PrefabUtility.InstantiatePrefab

PrefabUtility.InstantiatePrefab will be your friend. It will keep your prefab connections just like you always wanted them to be. (Editor use only)