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
  I have to refresh generator manualy :( GameDeveloperek4123 3 6 09-30-2024, 09:55 PM
Last Post: _Aka_
  Bug: Save Generator Outputs still saves outputs if object is disabled curvymesher 1 3 08-30-2024, 09:19 AM
Last Post: _Aka_
  How can I set the generator to stop updating? emerrryjones 1 8 07-26-2024, 10:07 AM
Last Post: _Aka_
  How to modify Input GameObject's transformation properties by script. j95677 2 6 07-05-2024, 06:28 PM
Last Post: j95677

Forum Jump: