Search Unity

Opening a prefab in prefab mode from script

Discussion in 'Prefabs' started by mudloop, Jun 25, 2019.

  1. mudloop

    mudloop

    Joined:
    May 3, 2009
    Posts:
    1,088
    Hi,

    As the title says, I'd like to know how to open a prefab in prefab mode from an editor script. I've been unsuccessful in my google searches so far.

    Use case is I'd like to build an editor panel that gives me quick access to the prefabs I need to edit frequently. Would save some time as opposed to finding them in the project panel (or scene, in some cases) each time.

    Any tips would be appreciated. Thanks!
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    3,947
    AssetDatabase.OpenAsset.

    @runevision, you're the one that told me about that method for opening assets in prefab mode. There seems to be one thread created every second day about "how do I open the prefab mode from editor script": It seems like it's really, really not obvious how to do this. You guys should add a utility method to one of the Prefab (PrefabUtility, PrefabStageUtility?) classes that people actually find.
     
    SugoiDev and SmartMediaNL like this.
  3. mudloop

    mudloop

    Joined:
    May 3, 2009
    Posts:
    1,088
    Thanks! And sorry for asking something that apparently gets asked a lot :)
     
    Baste likes this.