Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manipulate Generator properties in c#?
#1
Couldn't find any information on how to do this on the website.

I'm trying to manipulate the Length property of a Shape Extrusion module in a generator.

Thought it would be something like this but it seems the CGShapeExtrusion is not a class - 

Code:
GameObject go = GameObject.Find("Generator");
        CurvyGenerator gen = go.GetComponent<CurvyGenerator>();
        CGShapeExtrusion se = gen.GetModule<CGShapeExtrusion>("Shape Extrusion");


Any help much appreciated!
Reply
#2
Figured it out - 

Code:
        GameObject go = GameObject.Find("Generator");
        CurvyGenerator gen = go.GetComponent<CurvyGenerator>();
        BuildShapeExtrusion module = gen.GetModule<BuildShapeExtrusion>("Shape Extrusion");
        if (module.Length < 1.0f)
            module.Length += 0.01f;
        else
            module.Length = 0;
Reply
#3
Yes, that's the class. Most IDE have auto completion integrated in them. Using that, and by inputting the module's name, you can usually instantly find the class name. Also, the api reference is here for such cases. Here are the classes in the FluffyUnderware.Curvy.Generator.Modules name space: https://api.curvyeditor.com/710/namespac...dules.html
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#4
Great! I'm also trying to manipulate the Width for an Input Spline Shape using a 2D/Rectangle programmatically but I'm not seeing it in intellisense.



Code:
InputSplineShape splineShape = gen.GetModule<InputSplineShape>("Input Spline Shape");

        splineShape.Width

Appreciate the help!


Attached Files Image(s)
   
Reply
#5
Hi
(yourInputSplineShape.Shape as CSRectangle).Width
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
Thank you for the prompt response!
Reply
#7
Doesn't seem to work - 
Code:
InputSplineShape splineShape = gen.GetModule<InputSplineShape>("Input Spline Shape");

        CSRectangle rect = splineShape.Shape as CSRectangle;

Cannot convert type 'FluffyUnderware.Curvy.CurvySpline' to 'FluffyUnderware.Curvy.Shapes.CSRectangle' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion Assembly-CSharp, Assembly-CSharp.Player


Even if I try a cast - 

Cannot convert type 'FluffyUnderware.Curvy.CurvySpline' to 'FluffyUnderware.Curvy.Shapes.CSRectangle'

Thanks!
Reply
#8
ah sorry, my bad
splineShape.Shape.GetComponent<CSRectangle>()
Does this work?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#9
That did it! Thanks Smile
Reply
#10
You are welcome. 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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Volume Spots and Distance from generator topquarkone 5 526 09-16-2021, 08:17 PM
Last Post: _Aka_
  Have generator run only once topquarkone 6 565 09-14-2021, 02:05 AM
Last Post: topquarkone
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 771 06-17-2021, 01:59 PM
Last Post: _Aka_
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 1,197 06-09-2021, 12:42 PM
Last Post: _Aka_

Forum Jump: