Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug ProBuilder objects in prefabs break if you call PrefabUtility.RevertPrefabInstance

Discussion in 'World Building' started by dgoyette, Nov 30, 2023.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,202
    ProBuilder objects appear to have a major problem with calling PrefabUtility.RevertPrefabInstance to revert a prefab instance. This doesn't happen if you click "Overrides -> Revert All" in the inspector for the prefab. But calling PrefabUtility.RevertPrefabInstance with break the object.

    For example, I made a simple prefab containing a default PB cube:

    upload_2023-11-30_14-33-21.png

    Now, if I call PrefabUtility.RevertPrefabInstance too revert the TestObj prefab, this is the result:

    upload_2023-11-30_14-34-15.png

    The object disappears, there's now a strange [none] (Mesh Filter) object on the PB object, and both the PB Mesh Filter and the Mesh Collider has lost their reference to the Mesh.

    Now, although the object is "broken", it's recoverable. If I switch to a different scene and come back, the object will be restored. Or, I can select the object, switch to Vertex mode, and I can see the verts. If I move one of the verts, the object is restored:

    upload_2023-11-30_14-36-39.png

    Is there something you're expecting people to call on PB objects after calling PrefabUtility.RevertPrefabInstance? Is there some way to tell PB Objects to fix themselves?
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,202
    FWIW, it looks like the bug only occurs when RevertPrefabInstance is called with InteractionMode.AutomatedAction. Things seem okay if you pass InteractionMode.UserAction instead. Not sure why that would matter, but it seems to be the workaround I needed for now.
     
    Last edited: May 3, 2024
  3. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,977
    first thing i notice is the size is 0,0,0
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,202
    Probably due to the mesh being missing/None when this occurs.