Posts: 12
Threads: 4
Joined: Sep 2021
Hi - I am using a generator to add objects along a spline, via a script in Unity edit mode. This works fine: when I run the script, generators get placed in the hierarchy, and the objects are created correctly. However, it turns out that every time I play the game, these objects get generated again. How can I stop a generator from running during Play? I only want them to run once, in the editor, when I am putting together the scene.
Posts: 2,110
Threads: 92
Joined: Jun 2017
Hi
Unlike the impression I was under, there is indeed no way to avoid them getting generated when entering play mode. I will have to implement a solution to your problem. Until then, here is how you can do it:
In the CurvyGenerator.Update() method, add the following at the method start:
if (AutoRefresh == false) return;
Then set the AutoRefresh boolean in your generator's inspector to false. That should do the trick.
Let me know if you need further help
If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 4
Joined: Sep 2021
Sorry, but that doesn't work. If I put the statement in Update() at the beginning, the objects never seem to get generated at all ever, even from the editor.
Posts: 2,110
Threads: 92
Joined: Jun 2017
09-13-2021, 07:46 PM
(This post was last modified: 09-13-2021, 07:48 PM by _Aka_.)
Hi
Sorry, I assumed you were familiar with Auto Refresh.
When
auto refresh is set to false, the curvy generator refreshes only when you order it to, meaning clicking on the refresh button in its toolbar, or via the API.
So basically I was thinking that you would do the changes you need in edit mode, either by having auto refresh set to true or by manually refreshing, then when you want to enter edit mode you make sure auto refresh is false.
Is this a satisfying answer?
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 4
Joined: Sep 2021
Thanks, but I couldn't get that to work. If the patch was in CurvyGenerator.Update and AutoRefresh=false, the objects were never drawn via manual refresh . I got around the problem with AutoRefresh=false, and then by disabling the Generator components after drawing my initial objects (in a coroutine after a wait).
Posts: 2,110
Threads: 92
Joined: Jun 2017
(09-13-2021, 10:25 PM)topquarkone Wrote: If the patch was in CurvyGenerator.Update and AutoRefresh=false, the objects were never drawn via manual refresh
Oh sorry, you are completely right. Glad you found a workaround. Sorry for not being useful.
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 12
Threads: 4
Joined: Sep 2021
No problem! I do have another question, but I'll put in new thread.