Search Unity

Editor Script - make changes via script to selected prefabs in the Project view?

Discussion in 'Prefabs' started by redmotion_games, Aug 20, 2020.

  1. redmotion_games

    redmotion_games

    Joined:
    May 6, 2013
    Posts:
    84
    Using 2019.2.17f

    I have a lot of prefabs from a 3rd party that I would like to modify to have the contents set to static and on a specific (custom) layer. They may be instantiated at realtime.

    I currently have select the prefab in the PROJECT view, press open prefab to go into it, change the two settings mentioned, and click < to complete the edit. Is there scripting equivalents for these actions?

    Is this possible to automate as an editor script?

    PrefabUtility seems to be the correct starting place but many of the commands appear to act on prefabs in the scene view.

    Project view only has a "create" menu but I don't want to create something.

    Perhaps I need to create a hack? Instantiate the prefab in the scene, edit there with the script, apply overrides, and delete?

    A punt in the right direction would be most welcome :)
     
    Last edited: Aug 20, 2020
  2. redmotion_games

    redmotion_games

    Joined:
    May 6, 2013
    Posts:
    84
    Doesn't need a script, just select all the prefabs and set the settings in the property view.