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/namespace_fluffy_underware_1_1_curvy_1_1_generator_1_1_modules.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 Thumbnail(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
  Curvy Generator Exception niek352 2 7 07-14-2022, 02:59 PM
Last Post: niek352
  Zoom out in generator window? Mike Danielsson 1 2 06-22-2022, 03:44 AM
Last Post: _Aka_
Exclamation Runtime error when using Curvy Generator with Game Object Deform studentloan 3 13 04-22-2022, 09:00 PM
Last Post: _Aka_
  How can I save a curvy generator? linkinballzpokemon 3 12 04-12-2022, 05:41 PM
Last Post: linkinballzpokemon

Forum Jump: