Problem with disappearing probuilder meshes.

Hi,
Recently I have weird problem with disappearing meshes created in Probuiler 4.1.0

Couple of days ago I’ve created platforms using probuilder - everything was fine, I could edit them, duplicate them and so on. Right now, for the first glance everything is fine, I can move them in space, but I can’t edit them with probuilder and as soon as I use Undo, Duplicate or use any other action, the mesh vanish.

Have any of you got the same problem? Maybe know the solve for that…
Thanks for helping in advance!

Unity ver. 2018.3.12f1

Is ProBuilder still in your project, and do the mesh GameObjects still have a reference to the ProBuilderMesh component?

Thanks for respond.
Unfortunately ProBuilder is in my project and I believe there’s still reference to the PB mesh.


That’s strange, it shows the bounds as 0,0,0. If your MeshFilter mesh is still valid, then this script will be able to recover the mesh information. To use it, create a new folder in your project named “Editor”, then create a script with these contents. After, run the menu item “Tools > ProBuilder > Repair >
Rebuild Empty ProBuilderMesh Components” in each scene with broken meshes.

using System;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.ProBuilder;
using UnityEditor.ProBuilder;
using UnityEngine.ProBuilder.MeshOperations;
using UObject = UnityEngine.Object;

static class RepairEmptyComponent
{
    /// <summary>
    /// Menu interface for manually re-generating all ProBuilder geometry in scene.
    /// </summary>
    [MenuItem("Tools/ProBuilder/Repair/Rebuild Empty ProBuilderMesh Components", false)]
    public static void MenuForceSceneRefresh()
    {
        StringBuilder sb = new StringBuilder();
        ProBuilderMesh[] all = UObject.FindObjectsOfType<ProBuilderMesh>();

        for (int i = 0, l = all.Length; i < l; i++)
        {
            UnityEditor.EditorUtility.DisplayProgressBar(
                "Rebuild ProBuilder Objects",
                "Rebuilding ProBuilderMesh " + all[i].name + ".",
                ((float)i / all.Length));

            var mf = all[i].GetComponent<MeshFilter>();
            var sm = mf == null ? null : mf.sharedMesh;

            try
            {
                // If the ProBuilderMesh component data was lost somewhere, don't ToMesh() and nuke the existing (good)
                // mesh filter. Instead try rebuilding from the sharedmesh data.
                if (sm != null && sm.vertexCount > 0 && all[i].vertexCount < 1)
                {
                    var mesh = all[i];
                    var source = mesh.GetComponent<MeshFilter>().sharedMesh;
                    var materials = mesh.GetComponent<MeshRenderer>().sharedMaterials;
                    MeshImporter importer = new MeshImporter(mesh);
                    importer.Import(source, materials, new MeshImportSettings() { quads = true, smoothing = true, smoothingAngle = 1f });
                    mesh.ToMesh();
                    mesh.Refresh();
                    mesh.Optimize();
                }
            }
            catch (Exception e)
            {
                sb.AppendLine("Failed rebuilding: " + all[i] + "\n\t" + e);
            }
        }

        if (sb.Length > 0)
            Debug.LogError(sb.ToString());

        UnityEditor.EditorUtility.ClearProgressBar();
        UnityEditor.EditorUtility.DisplayDialog("Refresh ProBuilder Objects",
            "Successfully refreshed all ProBuilder objects in scene.",
            "Okay");
    }
}

I’m having a similar problem. I have used ProBuilder extensively in my project to create prefab objects and am being plagued with an issue where meshes will disappear from prefab instances within the scene when I play the game within Unity.

Note that not all of the prefab instances within the scene which were built using ProBuilder lose their meshes, i.e. if I place two identical pillar prefab instances in my scene, one might lose its mesh.

I have not been able to identify what is causing this behaviour after investigating it for days - the ProBuilder objects which lose their collider meshes appears to be completely random.

I’m using Unity 2019.3 and ProBuilder 4.3.0 preview 2.

Any help would be appreciated.

Try updating to the latest preview, there have been some fixes that may address your issues.

Hi kaarrrllll, thanks for the reply. I’ll try that and report back here.

That seems to have fixed the issue, many thanks.

1 Like

Hi,

I have the same issue as fellow members. I am working using ProBuilder 4.2.3 and Unity 2019.3.10f1.
I tried updating to preview.4 and preview.7 4.3.0 but both cause all meshes to disappear with is even worst.
I tried ‘Rebuild Empty ProBuilderMesh Components’ - did not help.

Any suggestions?

My meshes vanish when moving the gameobject position by code.
Do I need to uninstall probuilder to use the preview-version, or can I have both installed?

Same for me and and ‘Rebuild Empty ProBuilderMesh Components’ - did not help.

Lost everyhting ?? :frowning:

You can only have one version of ProBuilder installed, and it should be from the Package Manager (not the Asset Store).

That shouldn’t be a problem, can you post your code?

Were you working with a preview version as well?

@kaarrrllll I’m a little confused about where exactly is ProBuilder storing the shared meshes once you “ProBuilderize” them.
I have searched the docs but it doesn’t specify it.
I’m concerned of my meshes vanishing. I can export them, but then they are not editable anymore.
I have noticed that creating a prefab with a ProBuilderized mesh creates a new (different name) mesh at each instance.
So, how is ProBuilder really handling the meshes it generates?
Does it store the meshes in the scene like when you create a new mesh via script? Does it store them on a temp folder? Are the meshes stored inside the ProBuilder component in the gameobject? But how?
Thanks :slight_smile:

Meshes are stored in the scene as part of the ProBuilderMesh component.

So, just like any other New Mesh() you can generate on a regular script?

Not exactly, the ProBuilderMesh component is what contains the editable mesh data. It then compiles that to a UnityEngine.Mesh that is generated as-necessary.

1 Like

Hello Kaarrrllll! I used your script with ProBuilder, however my meshes from my objects will not come back.

Nice flamingos.

I don’t see a ProBuilderMesh component on the selected object. Did you export the meshes, or otherwise remove the ProBuilder components?

Hello,

I recently went to install probuilder again in the package manager. I had it installed previously, and am unsure how it got removed over the past few months. I believe it might have removed itself upon the unity update I did last month, but am unsure (as I used it extensively this past summer, but then went on to do other things, and came back and realized its no longer in packages folder). Oddly enough, even with probuilder not installed, all my probuilder objects in my scenes showed up correctly.

Now that I re-installed probuilder. I am having the same problem as the OP. Using Unity 2020.2.0f1. Using Probuilder 4.4.0. Installed via package manager. I tried all the latest versions (pro builder 5), and even went back a few versions, still no meshes appearing.

If I remove probuilder from the packagmanager after installing it, and re-open the same level, then the meshes re-appear again. But the second I install it again, they disappear again.

All of my meshes are now invisible and their Object Sizer (read only) are all set to 0,0,0. I still have the Probuildermeshfilter component, and there is a mesh there.

I tried to use the script above, but it gives this error after creating it:

“Assets\Editor\NewBehaviourScript.cs(44,30): error CS1501: No overload for method ‘Import’ takes 3 arguments”

Any ideas on why the script gives an error, and how to get back all my Probuilder models back?