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


Messages In This Thread
Create MeshBuilder and Detach in one step? - by puzzlekings - 01-04-2015, 07:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create Game Object Renaming Options rickgplus 1 948 09-23-2025, 09:33 AM
Last Post: _Aka_
  Create Mesh Node, Make Static Options rickgplus 1 1,835 01-23-2025, 10:12 AM
Last Post: _Aka_
Heart Create beautiful curves ShiroeYamamoto 3 2,748 03-26-2024, 06:25 PM
Last Post: _Aka_
  Is it possible to create a road texture at runtime? artsung 1 1,548 01-30-2024, 09:30 AM
Last Post: _Aka_

Forum Jump: