protected override void generateModel(GameObject root) { CylinderMeshGenerator gen2 = new CylinderMeshGenerator(new Vector3(0, -height / 2f, 0), cylinderSides, height, radius, radius, radius - thickness, radius - thickness); gen2.outsideUV = outsideUV; gen2.insideUV = insideUV; gen2.topUV = topUV; gen2.bottomUV = bottomUV; Mesh mesh = gen2.generateMesh(); MeshFilter mf = root.GetComponent<MeshFilter>(); if (mf == null) { mf = root.AddComponent<MeshFilter>(); } MeshRenderer mr = root.GetComponent<MeshRenderer>(); if (mr == null) { mr = root.AddComponent<MeshRenderer>(); } mf.mesh = mesh; MeshCollider mc = root.GetComponent<MeshCollider>(); if (mc != null) { Component.DestroyImmediate(mc); } if (meshColliderConvex) { mc = root.AddComponent<MeshCollider>();//re-init mesh collider mc.sharedMesh = mesh; mc.convex = true; } else { GameObject[] cols = gen2.generateColliders(); int len = cols.Length; for (int i = 0; i < len; i++) { cols[i].transform.NestToParent(root.transform); } } }
protected override void generateModel(GameObject root) { CylinderMeshGenerator gen2 = new CylinderMeshGenerator(new Vector3(0, -height / 2f, 0), cylinderSides, height, radius, radius, radius - thickness, radius - thickness); gen2.outsideUV = outsideUV; gen2.insideUV = insideUV; gen2.topUV = topUV; gen2.bottomUV = bottomUV; Mesh mesh = gen2.generateMesh(); MeshFilter mf = root.GetComponent<MeshFilter>(); if (mf == null) { mf = root.AddComponent<MeshFilter>(); } MeshRenderer mr = root.GetComponent<MeshRenderer>(); if (mr == null) { mr = root.AddComponent<MeshRenderer>(); } mf.mesh = mesh; MeshCollider mc = root.GetComponent<MeshCollider>(); if (mc != null) { Component.DestroyImmediate(mc); } mc = root.AddComponent<MeshCollider>();//re-init mesh collider mc.sharedMesh = mesh; }
protected override void generateModel(GameObject root) { CylinderMeshGenerator gen2 = new CylinderMeshGenerator(new Vector3(0, -height / 2f, 0), cylinderSides, height, radius, radius, radius - thickness, radius - thickness); gen2.outsideUV = outsideUV; gen2.insideUV = insideUV; gen2.topUV = topUV; gen2.bottomUV = bottomUV; Mesh mesh = gen2.generateMesh(); MeshFilter mf = root.GetComponent <MeshFilter>(); if (mf == null) { mf = root.AddComponent <MeshFilter>(); } MeshRenderer mr = root.GetComponent <MeshRenderer>(); if (mr == null) { mr = root.AddComponent <MeshRenderer>(); } mf.mesh = mesh; MeshCollider mc = root.GetComponent <MeshCollider>(); if (mc != null) { Component.DestroyImmediate(mc); } if (meshColliderConvex) { mc = root.AddComponent <MeshCollider>();//re-init mesh collider mc.sharedMesh = mesh; mc.convex = true; } else { GameObject[] cols = gen2.generateColliders(); int len = cols.Length; for (int i = 0; i < len; i++) { cols[i].transform.NestToParent(root.transform); } } }
public void enableEditorCollider(bool val) { if (editorCollider != null) { GameObject.Destroy(editorCollider); } if (val) { float maxHeight = getHeight(); Vector3 offset = new Vector3(0, maxHeight - editorColliderHeight, 0); CylinderMeshGenerator cmg = new CylinderMeshGenerator(offset, 12, editorColliderHeight, getBottomRadius(), getTopRadius(), 0, 0); Mesh mesh = cmg.generateMesh(); editorCollider = new GameObject("PetalAdapterEditorCollider"); MeshFilter mf = editorCollider.AddComponent <MeshFilter>(); mf.mesh = mesh; MeshCollider mc = editorCollider.AddComponent <MeshCollider>(); mc.convex = true; mc.enabled = true; } }
public void enableEditorCollider(bool val) { if (editorCollider != null) { GameObject.Destroy(editorCollider); } if (val) { float maxHeight = getHeight(); Vector3 offset = new Vector3(0, maxHeight - editorColliderHeight, 0); CylinderMeshGenerator cmg = new CylinderMeshGenerator(offset, 12, editorColliderHeight, getBottomRadius(), getTopRadius(), 0, 0); Mesh mesh = cmg.generateMesh(); editorCollider = new GameObject("PetalAdapterEditorCollider"); MeshFilter mf = editorCollider.AddComponent<MeshFilter>(); mf.mesh = mesh; MeshCollider mc = editorCollider.AddComponent<MeshCollider>(); mc.convex = true; mc.enabled = true; } }