Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create MeshBuilder and Detach in one step?
Hi Jake,

I am trying to add another button to the spline tools that creates a Mesh Builder and Detaches in one step using the script below, but I am having a few problems.

Essentially the Detached gameobject seems to have its mesh filter uninitialised, even though the Mesh Filter Component says CurvyMesh.

Also, I want to delete the MeshBuilder object itself, only to be left with the detached GameObject which should have its own mesh.

Could you please tell me what is the best way to achieve this? 



[font][ToolbarItemInfo(Text = "Mesh-Bld-Nalin"Tooltip = "Create a Mesh Builder"Image = "meshbuilder,24,24",
                     Order = 83AppliesTo = ToolbarItemTarget.Spline | ToolbarItemTarget.Group)]
    public class TBSplineCreateMeshBuilderNalin : ToolbarItem
        public override void Action()
            var mb = SplinePathMeshBuilder.Create();
            mb.Spline = (CurvySplineBase)Toolbar.Selection[0];
            // Nalin - try to position it in the same place
            mb.transform.position = Selection.activeGameObject.transform.position;
            // Rectangle and other parameters
            mb.UV = SplinePathMeshBuilder.MeshUV.Absolute;
            mb.CapShape = SplinePathMeshBuilder.MeshCapShape.Rectangle;
            mb.CapWidth = 6;
            mb.CapHeight = 0.5f;
            mb.gameObject.renderer.castShadows = false;

            // stripy material
            Material material = (Material)Resources.LoadAssetAtPath("Assets/Curvy/Examples/ScriptsAndData/Mat_BlackWhite.mat"typeof(Material));
            mb.gameObject.renderer.material = material;

            // create detach version because we don't need intermediate version
            Transform detachedMB = mb.Detach();

            Selection.activeGameObject = detachedMB.gameObject;
            Undo.RegisterCreatedObjectUndo(Selection.activeGameObject"Create Mesh Builder");

Looks like you detach it before actually running it, please try to call mb.Refresh() before mb.Detach().
Awesome - thanks so much - this did the trick Smile



BTW - what news of V2? features/timescales?
Timescale is 20xx Wink

Just kidding...Core and UI changes are done, I'm currently reworking examples and documentation and fixing bugs. Then I'll release a public (well, limited to Curvy users) beta while working on some missing modules for the new PCG, then it will be released.

BTW I did have a suggestion for V2 - gaps in the curve for jumps etc. by making control points active / inactive:

Is this feasible/possible?

BTW seems to work quite well with Snazzy Grid as well.


Just use several MeshBuilders and set the From/To range accordingly.
Cool - thanks for that - should have spotted it myself

Possibly Related Threads…
Thread Author Replies Views Last Post
Heart Create beautiful curves ShiroeYamamoto 3 13 03-26-2024, 06:25 PM
Last Post: _Aka_
  Is it possible to create a road texture at runtime? artsung 1 4 01-30-2024, 09:30 AM
Last Post: _Aka_
  Combine 2 Create Mesh nodes to one single Mesh danne_lindwall 1 13 02-16-2023, 08:25 PM
Last Post: _Aka_
  How to create gaps in spline mesh? linkinballzpokemon 1 6 04-09-2022, 12:29 PM
Last Post: _Aka_

Forum Jump: