Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create MeshBuilder and Detach in one step?
#1
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? 

thanks

Nalin

[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");
            
        }
    }[/font]

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

cheers

Nalin

BTW - what news of V2? features/timescales?
Reply
#4
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.
Reply
#5
Thanks

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

http://forum.unity3d.com/threads/released-curvy-fast-spline-interpolation.170355/page-6

Is this feasible/possible?

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

cheers

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


Possibly Related Threads…
Thread Author Replies Views Last Post
Heart Create beautiful curves ShiroeYamamoto 3 9 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: