12-05-2016, 09:44 PM
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!
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!