private GameObject[] MakeRope(GameObject go, float length) { var meshGenerator = new RopeMeshCylinderGenerator(); var material = new Material(Shader.Find("Diffuse")); var tmpRope = new RopeGenerator(meshGenerator, material, go); tmpRope.Length = length; tmpRope.BoneCount = Math.Max((int)length, 2); return(tmpRope.MakeOne()); }
private void MakeRope() { if (_meshGenerator == null) { Debug.LogError("MeshGenerator is not specified"); return; } var go = new GameObject("New Rope (" + (++_genCounter).ToString() + ")"); go.transform.localPosition = new Vector3(0, 0, 0); go.transform.rotation = Quaternion.FromToRotation(Vector3.right, Vector3.down); if (_parrent != null) { go.transform.parent = _parrent.transform; } var tmpRope = new RopeGenerator(_meshGenerator, go); ApplayParams(tmpRope); var result = tmpRope.MakeOne(); if (_optimizeMesh) { MeshUtility.Optimize(result.Mesh); } if (_saveMesh) { var path = EditorUtility.SaveFilePanel( "Save mesh", "", "new_mesh.asset", "asset"); path = FileUtil.GetProjectRelativePath(path); if (path.Length != 0) { AssetDatabase.CreateAsset(result.Mesh, path); AssetDatabase.SaveAssets(); } } }