Search Unity

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

Discussion in 'World Building' started by dgoyette, Dec 18, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,239
    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:

    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.
     
  2. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    698
    Hi! No need to enable the experimental option, it will work fine. Just looks a little strange for now, sorry!
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,239
    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?
     
  4. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    698
    Yep, precisely :)
     
    dgoyette likes this.
  5. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    33
    @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.
     
  6. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    33
    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.
     

    Attached Files:

  7. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    698
    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! :)
     
  8. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    33
    "Meshes are Assets" works pretty poorly for us. :p 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.
     
  9. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    698
    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!
     
  10. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    33
    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.
     
  11. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    698
    Ah, ok - got it, found it, logging a bug now. Thanks for the info!
     
  12. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    33
    Thanks for looking into it!
     
  13. wbd_lludo

    wbd_lludo

    Joined:
    Jan 14, 2019
    Posts:
    1
    Hi everybody !

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

    @gabrielw_unity
     
  14. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    698
    Hi wbd_lludo - which issue are you referring to? :)
     
  15. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    110
    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.
     
  16. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    194
    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).
     
    dgoyette likes this.
  17. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,239
    This is good to hear. I'll check out 4.3.0-preview.2 when I see it.
     
  18. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,239
  19. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    110
    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.

    Capture.PNG
     
  20. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    110
    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?
     
  21. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    194
    Yes, that's possible. If you have the time could you please file a bug report?
     
  22. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    110
    Disabling "Script Stripping" ended up being my temp fix for the build issue.

    Another issue I came across is mesh colliders stop working because they can no longer find a mesh on the probuilder object. I think this might be due to the probuilder update migration, since creating a new probuilder object has a proper mesh reference on the mesh collider.

    EDIT: Submitted a bug report for the disappearing geo build issue: 1214103
     
    Last edited: Jan 23, 2020 at 6:04 PM
    kaarrrllll likes this.
unityunity