I’m looking into using ProBuilder’s Bezier Shape (under the experimental features) to create a closed loop path.
I know exactly how many points I want to put on the Bezier Shape and the coordinates I want to place each of those points at. I can do this very simply through the GUI, but I want to automate it by using a script. (The reason for automating it is because I have a large set of points I want it to use and I want it to be applicable to multiple configurations/projects).
Looking at the ProBuilder API, I do not see a way to do the following to the Bezier Shape.
Add points to the Bezier Shape
Change the position of the points
Are there any script examples of how I could do this?
I’m sorry, but it looks like ProBuilder does not currently have an API for working with Bezier shapes. The experimental features in ProBuilder, including the Bezier shape tool, are still under development and are not currently supported in the API.
If you want to automate the creation of Bezier shapes using a script, you may need to use a different tool or approach. There are a few different options you could try:
Use the Unity built-in LineRenderer component: The LineRenderer component allows you to draw lines and curves in the scene using a set of control points. You can use a script to set the control points and the curve settings on the LineRenderer, and it will automatically generate the Bezier curve for you. This approach is relatively simple, but it does not provide as much control over the curve as ProBuilder’s Bezier shape tool does.
Use a third-party Bezier curve library: There are several third-party libraries available that allow you to create and manipulate Bezier curves in Unity. For example, you could try using the Bezier Curve for Unity package, which provides a set of classes for working with Bezier curves. This approach will give you more control over the curve than the LineRenderer approach, but it may be more complex to set up.
Use a custom script to generate the curve: Finally, you could write a custom script that generates a Bezier curve using the control points you specify. This will give you the most control over the curve, but it will also require the most effort to implement. You can find many examples of how to generate Bezier curves using a set of control points online, which you can use as a starting point for your own script.