Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CG CreateGameObject and Prefabs
#1
One of our uses for CurvyGenerator is to automatically build and place repetitive geometry in environment assets. For example, we'll use it to generate columns around the perimeter of a Roman temple. We would then like to turn the entire GameObject into a prefab and use those prefabs across several scene environments.

However, we're having an issue when it comes to turning these assets into prefabs. An asset with CurvyGenerator can be turned into a prefab just fine, but if we instantiate it, it will immediately lose its prefab connection. I believe this is due to CurvyGenerator.Update() in the editor, which is called due to ExecuteInEditMode. It will immediately call Initialize(), which in turn will call Refresh(true). This causes a CreateGameObject module in the generator to refresh, deleting its current managed resources while creating new ones. This last bit is what breaks the prefab connection.

This isn't ideal for us, so I was wondering what the recommended workflow is for our use case? Currently, the only ways I see around this are to either disable the CreateGameObject module after generating its resources at edit time, or to not include the CurvyGenerator in the prefab and instead generate the geometry separately, after which we pull the geometry into the prefab and update it. Both of these solutions aren't super satisfactory, since it adds extra steps (and potential opportunities for forgetfulness or mistakes) to our prefab process. Do you recommend a different approach?

Thanks!
Reply
#2
Currently the best solution is to detach the generated geometry from the CG and prefab just that. You can use the SaveToScene method of the CrateMesh module to detach the resulting meshes.
Reply
#3
(01-15-2017, 09:28 AM)Jake Wrote: Currently the best solution is to detach the generated geometry from the CG and prefab just that. You can use the SaveToScene method of the CrateMesh module to detach the resulting meshes.

Thanks! I'll look into that and talk with my artists.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Generators placing referenced prefabs Horibe 8 479 07-05-2019, 10:40 AM
Last Post: _Aka_
  Splines control point Mixup with prefabs Yvain 7 5,793 04-30-2016, 01:22 PM
Last Post: Jake
  Splines as random prefabs in Playmaker? Avrigus 0 2,145 07-24-2014, 10:32 PM
Last Post: Avrigus

Forum Jump: