Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setup Generators in code
#1
I'm trying to setup and generate geometry in code. Is there any extra documentation on how to do this or example code?

Also, would it be advisable to reuse the same generator, would the memory footprint be high if there is a generator attached to each spline? ( I would have over 1000)
Reply
#2
Hi Jake, I'm not sure why your previous response has been deleted. I'm trying to use the approach you described but I'm receiving an error:

"The object you want to initiate is null" stack trace refering to the CreateMesh.cs: 457

I'm attempting to use the generator you setup in the examples 15_CGExtrusionAdvanced with my own spline data, using the following code. Any thoughts on where this is going wrong?

Code:
       Track[] tracks = trackList.Track;

       CurvyGenerator cgen = FindObjectOfType(typeof(CurvyGenerator)) as CurvyGenerator;

       cgen.AutoRefresh = false;
       List<CreateMesh> cm = cgen.FindModules<CreateMesh>();

       for (int i = 0; i < MAX_TRACKS; i++)
       {
           ArrayList coords = Strings2Vec3Arr(tracks[1]);
           GameObject instance = InstantiateSectie(coords);

           attachCurvySpline(instance, coords);

           cgen.Refresh();

           foreach (CreateMesh cm_i in cm)
           {
               cm_i.SaveToScene();
           }

       }
Reply
#3
Just a guess: Are you doing this in Start() without waiting for your splines to be fully initialized? Otherwise it would be nice to get a scene reproducing the error. You can send it to jake<at>fluffyunderware.com

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Import/Export, Spline from code Mos Def 4 782 02-14-2022, 11:42 AM
Last Post: _Aka_
  Code snippet to automatically set UV Edge to true _Aka_ 0 3 12-20-2021, 04:29 PM
Last Post: _Aka_
  How can I modify generators during gameplay ? codehawk64 2 426 09-03-2021, 10:18 AM
Last Post: codehawk64
  Compilation issues for iOS with a scene containing generators puzzlekings 2 911 05-13-2021, 06:53 PM
Last Post: _Aka_

Forum Jump: