Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating multiple object on changing transform
#11
Hi spedepasanen,
I was just reading my this old post remembering when I was working with Curvy Splines for a game. Just saw that you are facing this problem that even on removing the generated meshes from prefabs still on playing game in editor it regenerates new meshes and doesn't destroy previous ones. The issue is new Unity Prefab system sucks. I once when I was working on generating splines made a prefab of my track and this issue occurred and then I "Completely Unpacked my Prefab" so curvy could destroy previous generated meshes, but surprise, Unity still didn't allow it to destroy previous generated meshes. I was really very short of time with my project so I had to again manually delete all generated meshes from my prefab and then save the prefab to avoid multiple generated meshes. If you have time and you could find out the solution of this problem, do share it in this post.
Regards.
Reply
#12
(08-23-2019, 12:36 PM)spedepasanen Wrote:
(08-22-2019, 02:39 PM)_Aka_ Wrote: As you might already know, the objects with blue names are part of the prefab, and with black names are not part of it.
So you already not include the generated mesh objects in the prefab, which is the right thing to do.

The sentence you are asking about:
"So the solution is to not include the generated objects in your prefab, which is the right thing to do anyway, to avoid having huge prefabs."
was said to a user which included all the generated objects in the prefab. In other words, all his objects had names in blue, which is not your case.

Yes I managed to remove the mesh from the prefab, but Curvy creates a new instance of the mesh everytime I run the game in the editor, resulting multiple useless meshes.

In the image you can see the Create Mesh_6_Mesh000 gameobject hasbeen created twice, first instance was created on the first time I pressed play, second on the second startup, first instance is not interactable. If I would start the game again a third instance would show up and so on.. How can I stop the the duplicate mesh creation/delete the earlier created mesh.

For future reference, I managed to reproduce spedepasanen's issue, and will work on it soon
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#13
(08-22-2019, 02:19 PM)spedepasanen Wrote: Hello,
I came across issue with prefabs and curvy just now, and I dont quite get what this means:
(06-28-2019, 07:13 PM)_Aka_ Wrote: So the solution is to not include the generated objects in your prefab, which is the right thing to do anyway, to avoid having huge prefabs.

I tried removing the created mesh from the prefab(I just deleted the created mesh and then saved the prefab), but that results a multiple meshes when I run the game on Editor. What would be the correct way to do this so I dont end up with multiple duplicate generated meshes?

[Image: Sieppaa.PNG]

Hi
I find a solution: Add this line
r.gameObject.hideFlags = HideFlags.DontSave;
just before this one
r.Renderer.shadowCastingMode = CastShadows;
in the method getNewMesh from the CreateMesh class.

This solution is not perfect, because when applied and you try to compute global illumination, Unity will display the following message:
Some MeshRenderers cannot contribute to global illumination, because their HideFlags are set to DontSaveInEditor, HideAndDontSave or DontSaveInBuild.

So I will keep looking for a better solution, but you can use this one for now
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  Generating GO only on CPs in Generator GameDeveloperek4123 1 6 03-04-2024, 11:06 AM
Last Post: _Aka_
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_
  Removing the objects behind an object alms94 6 6 12-06-2023, 09:31 PM
Last Post: _Aka_

Forum Jump: