PB Meshes don't play nicely with Improved Prefab workflow?

Is it necessary to enable the “experimental” Meshes as Assets feature in order for PB objects to behave cleanly in prefabs under 2018.3? By “cleanly”, I mean that currently every prefab instance I have that contains a PB object considers itself to have overrides, because the Mesh is different. For example:

4012054--346426--upload_2018-12-18_10-48-50.png

No matter how many times I Apply or Revert these overrides, they remain overrides. If I go into Prefab mode, the actual prefab has a different Pb_mesh-xxxx ID.

I’m hesitant to enabled an “Experimental” PB feature though, especially as I don’t know anything about it, or whether there’s a better way for PB objects not to act like overrides in prefabs.

Hi! No need to enable the experimental option, it will work fine. Just looks a little strange for now, sorry!

Thanks. Meaning that in some future release of Unity or ProBuilder, Unity will stop telling me that my prefab instance containing PB meshes has overrides due to the PB mesh?

Yep, precisely :slight_smile:

1 Like

@gabrielw_unity Can you elaborate on what’s happening here? We are seeing issues handling prefabs and prefab instances using Unity 2018.3.5 and ProBuilder 4.04.

It appears that ProBuilder is aggressively regenerating meshes across instances of prefabs, even if they should share the same mesh as the prefab asset. The repro is very simple: create a new PB cube mesh and make it a prefab. Then drag that prefab into a scene. Notice that the mesh on the instance is different than the mesh on the asset, and the instance has been flagged as having an override

This happens whether or not Meshes are Assets is checked. This is odd to me since, digging through the the ProBuilder package source, it appears that Meshes are Assets should be causing ProBuilder to attempt to cache and re-use the same mesh across instances and assets.

This is causing one major issue for us currently, and I’m worried it may be less obviously causing several more.

The obviously apparent issue is that loading a scene containing large ProBuilder meshes takes freaking forever, spending multiple minutes in a call to Prefabs.MergePrefabs() from LoadLevelAsync() – my guess is that all the meshes are being regenerated during deserialization, causing extremely long hangs.

The other issues I’m concerned about are purely hypothetical, but I’m guessing that this could be bloating our application’s memory budgets at runtime. If we have 100 instances of the same ProBuilder prefab, will we be generating 100 identical meshes to store in memory?

If you’re able to shine any light on what is happening here and what possible workarounds are, I’d be very grateful. Right now I don’t know if we’re running into a bug, or if we’re just misunderstanding the way in which ProBuilder is intended to be used. The repro steps I mention feel extremely broken to me, but it’s possible I’m just confused about what is happening under the hood.

One of my coworkers just build a min repro project that confirms that the issue still occurs on 2018.3.10. In the min repro project, it’s really apparently that we’re just generated new meshes all over the place – every time you drag the Cube prefab into a scene, you can see a new mesh asset generated on-disk and added to the ProBuilderMeshCache folder.

4362271–394879–ProBuilderTest.zip (22.3 KB)

Hi! Yep, we see this problem and are working toward a solution. It’s not a quick one, unfortunately. You can use the experimental “Meshes are Assets”, if you like - in fact it’d be great to hear how that works for you! :slight_smile:

“Meshes are Assets” works pretty poorly for us. :stuck_out_tongue: It does the same ‘generate meshes all the dang time’ behavior, with the added fun of writing a new asset to disk and incurring the file I/O costs.

We’ve ended up writing our own code to build out the generated mesh to our own asset cache and delete the ProBuilderMesh script entirely when we’re not actively editing the meshes. It’s a little gross, but it means our scenes load in 5-10 seconds instead of the 10 minutes it was taking before.

1 Like

Hi, can you clarify “generate meshes all the dang time”? With “Meshes are Assets” (MaA), a new mesh should only be generated once, when the object is created. Are you seeing something different? Thanks!

Correct. The simple repro was:

  • Make a Probuilder cube
  • Make it a prefab (drag it into the project view)
  • Drag that prefab into the scene to create an instance
  • Look at the instance in the inspector and note that it has generated a new mesh asset and overridden the prefab mesh references

Looking at Probuilder’s code, it looks like it attempts to reuse the same mesh across prefab assets and instances if Meshes are Assets is enabled, but for some reason that was not working properly for us.

Ah, ok - got it, found it, logging a bug now. Thanks for the info!

Thanks for looking into it!

Hi everybody !

Is this issue resolved ? Because i have the same problem here. :confused:

@gabrielw_unity

Hi wbd_lludo - which issue are you referring to? :slight_smile:

Is there an ETA on fixing the original problem mentioned in this thread–namely prefabs always thinking PB objects have overrides? It’s making it hard to maintain prefabs and whether they’re up to date.

Yes, a PR just landed addressing this issue as well as other prefab related bugs.

https://github.com/Unity-Technologies/com.unity.probuilder/pull/221

The fix is first appearing in ProBuilder 4.3.0-preview.2, which should be available within a few hours in Package Manager (make sure you have “Preview Packages Enabled” toggled to “On” to see the update).

1 Like

This is good to hear. I’ll check out 4.3.0-preview.2 when I see it.

Have you guys not published an update to the Changelog for this release? Or is there something going on with docs.unity3d.com that isn’t showing the latest changelogs? The site is still only showing changelog info through
4.3.0-preview.1.

I can see the changelog changes on github. I’m just curious why it’s not in the docs site. (com.unity.probuilder/CHANGELOG.md at rc-4.3.0-preview.2 · Unity-Technologies/com.unity.probuilder · GitHub)

So I tried 4.3.0-preview2 this morning but it doesn’t appear to have addressed the prefab override issue yet. Here’s what I’m seeing for overrides. Going inside the prefab and saving it doesn’t help, as well as applying all changes or reverting all changes.

Also it looks like w/ 4.3pr2 when I make a windows build all my probuilder geometry disappears. Possibly related to the mesh filter change?