Anatta336 / driven-decals

A mesh-based PBR decal system for Unity's universal render pipeline.
MIT License
576 stars 75 forks source link

Prefabs not working correctly #8

Open SBird1337 opened 3 years ago

SBird1337 commented 3 years ago

When adding a decal to a prefab the Editor Tool does not recognize static meshes, if you deselect All static meshes and apply it to a mesh manually it will render correctly at first, but after re-opening the prefab or placing it in a scene the decal will disappear.

Steps to reproduce:

  1. Create an empty game object as a prefab
  2. Add a mesh object
  3. Add a Driven Decal Asset
  4. Project the mesh
  5. Close the prefab tab
  6. Re-open the prefab Tab
  7. The decal is gone.
Anatta336 commented 3 years ago

Thank you for the report. I've been able to reproduce the issue, and will work on fixing it. It's definitely something that needs correcting!

richgizmo commented 3 years ago

Hi, I've got the same problem with prefabs not updating and decals disapearing.

kriller509 commented 3 years ago

Can confirm it doesn't work with prefabs & that prefabs instantiated it also breaks with. This will probably prevent me from using it on our project unfortunately ;-;

chisely commented 3 years ago

This is probably because the generated decal mesh is not properly serialized and saved by Unity when prefab is closed.

The workaround to similar issues seems to be to use some sort of simple serialization to store the mesh data in the prefab. Example: https://forum.unity.com/threads/solution-save-a-prefab-with-a-generated-mesh-es-without-creating-assets.463496/

I'll test it and report back.


Edit: Yep, using the script from the thread above the prefabs indeed do work correctly.

The workflow is:

  1. Open prefab in prefab mode
  2. Create Decal gameobject and project it.
  3. Add the SerializeMesh script to decal gameobject (from link above)
  4. Click "Serialize" on SerializeMesh script.
  5. Save the prefab.

Now, if the prefab is instantiated during runtime, the decals are properly displayed.