0
\$\begingroup\$

I am using a Unity asset to combine many meshes of many objects in my scene to one object. The name of this asset is "Mesh Combiner", and here is the link to the asset: https://assetstore.unity.com/packages/tools/modeling/mesh-combiner-157192

After this tool combines the meshes, it creates and saves a file with the extension ".asset". But, this is not a prefab that I can drag-and-drop to a scene.

My question is: Can I manually change the extension of this file from ".asset" to ".prefab", and use it as a prefab in my new scene ?

\$\endgroup\$
3
  • 1
    \$\begingroup\$ That doesnt make sense. A mesh is not a prefab, so renaming won't do anything. Assign your combined mesh to something and make a prefab out of that? \$\endgroup\$
    – Zibelas
    Commented Feb 27 at 13:07
  • 1
    \$\begingroup\$ Be careful when combining many meshes into one object. Combining meshes can improve performance if most or all of the meshes are visible at the same time. However, if the meshes are spread out and only some of them will be visible at a time, combining them all into one may make performance worse, because it prevents culling. \$\endgroup\$
    – Kevin
    Commented Feb 27 at 23:55
  • 1
    \$\begingroup\$ Also note that for static meshes using the same material, Unity performs this optimization automatically, and it can also do a limited amount of mesh combining with dynamic meshes at runtime, so you might not benefit from doing it by hand. \$\endgroup\$
    – DMGregory
    Commented Feb 28 at 3:52

1 Answer 1

4
\$\begingroup\$

You do not "convert" an asset to a prefab. These are different things that serve different purposes. A prefab is a game object that can exist in your scene. An asset is the raw data that a game object might reference, but it cannot exist in a scene on its own. You never have a "mesh asset" in your scene, you have game objects with rendering components that reference the mesh asset they want to render. This indirection is helpful - it allows you to share one set of mesh data among many instances, without needing to store many copies of it (flyweight pattern).

What you can do is create a prefab that references the combined mesh asset this way:

  1. Create a new Empty GameObject.

  2. Add MeshFilter and MeshRenderer components to it. The MeshFilter selects the mesh to be rendered, and the MeshRenderer handles rendering it and configuring the materials and settings for that rendering.

  3. Set the MeshFilter to use the mesh asset generated by the combiner tool.

Now you have a GameObject that renders this mesh, and you can populate its materials as desired.

Drag that GameObject into your Project tab to create a prefab of that new object.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .