Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Have generator run only once
#1
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.
Reply
#2
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
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.
Reply
#4
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
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).
Reply
#6
(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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#7
No problem! I do have another question, but I'll put in new thread.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Volume Spots and Distance from generator topquarkone 5 110 09-16-2021, 08:17 PM
Last Post: _Aka_
  Manipulate Generator properties in c#? blabz2007 9 1,021 06-18-2021, 09:17 AM
Last Post: _Aka_
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 503 06-17-2021, 01:59 PM
Last Post: _Aka_
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 780 06-09-2021, 12:42 PM
Last Post: _Aka_

Forum Jump: