Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Editor Applying Prefabs Automatically / Excessively

Discussion in 'Editor & General Support' started by oneofmoo, Nov 21, 2017.

  1. oneofmoo

    oneofmoo

    Joined:
    Aug 18, 2016
    Posts:
    12
    Unity Version: 5.6.0f3 on OSX

    I'm having an issue where certain level instances will get applied to a prefab without me ever having pressed the apply button.

    I have yet to have a 100% repro case, but it usually is something like this.
    1. Have modified instance parameters on a prefab instance
    2. Go into play mode
    3. Change some values in play mode
    4. End play mode

    Result: All instance changes (the ones from before play mod was started and the ones made during play mode) have been applied to the prefab. It's entirely as though I had pressed the Apply button in the Prefab Instance Manager.

    As you can imagine, this can be very destructive to my scene and I generally have no choice but to simply revert the entire scene and prefab. Is anyone else experiencing this or anything similar? Are there any work arounds? Any help would be massively appreciated.
     
  2. murgonen

    murgonen

    Joined:
    May 24, 2017
    Posts:
    4
    We have this same issue, but it's consistent. Every time when going to play mode in editor, object selected in Hierarchy applies its changes to its prefab. We are using Unity 2017.3.0f3 on Windows. We need to always select non-prefab game object before going to play, to prevent accidental prefab applyings.

    It started couple of months ago, but it's hard to find what is causing this. I did an editor script that deselects objects from Hierarchy when going to play mode, but it doesn't work, the prefab gets applied before playModeStateChanged event is hit.

    We have no PrefabUtility.ReplacePrefab calls in our project. It happens on every machine running this project, but it doesn't happen when creating a new project.
     
  3. oneofmoo

    oneofmoo

    Joined:
    Aug 18, 2016
    Posts:
    12
    @murgonen We tracked it down by registering a callback to UnityEditor.PrefabUtility.prefabInstanceUpdated and checking the call stack. It turned out to be a third party plugin that was causing the problem. Luckily, the plugin had a clear option to toggle off the offending feature and I have notified them of the issue it was causing for us.
     
    murgonen likes this.
  4. murgonen

    murgonen

    Joined:
    May 24, 2017
    Posts:
    4
    Hey @oneofmoo thank you very much!

    With the `PrefabUtility.prefabInstanceUpdated` I also managed to find the culprit for this. It too was because of a third party plugin (Fabric Audio), which has a seemingly malfunctioning setting for applying play mode changes to prefab.

    Whew, this really plagued our whole team for months.
     
  5. oneofmoo

    oneofmoo

    Joined:
    Aug 18, 2016
    Posts:
    12
    Yup. Same. I've let him know about the issue and I believe he will put in a fix soon.
     
    murgonen likes this.