/// <summary> /// adds an existing element in the constructed list /// </summary> /// <param name="mesh"></param> public void AddExistingElement(GameObject go) { MyMesh mesh = new MyMesh(go); //mesh.obj.AddComponent<BoxCollider>(); mesh.obj.AddComponent<GetSelected>(); mesh.obj.AddComponent<AdditionnalProperties>(); AdditionnalProperties prop = mesh.obj.GetComponent<AdditionnalProperties>(); prop.ID = currentID + 1; currentID++; constructedElements.Add(mesh); }
/// <summary> /// create an object with the given element /// </summary> /// <param name="basicElement">the BasicElement to build</param> /// <param name="position">the position of the BasicElement</param> /// <param name="currentID">the ID of the BasicElement</param> private static void CreateObject(BasicElement basicElement, int position, int currentID) { basicElement.Build(); // the mesh is updated when triangulating in the build function MyMesh mesh = new MyMesh(basicElement.GetMesh().triangles, basicElement.GetMesh().vertices); // here you get that mesh (OpencascadePart.MyMesh) and you convert it into an Assets.MyMesh // if you need to refresh MyMesh for some reasons, you can update the faces the way you wish and then call basicElement.RecalculateMyMesh() mesh.obj.transform.localScale = new Vector3(1, 1, 1); mesh.obj.AddComponent<BoxCollider>(); mesh.obj.transform.position = new Vector3(1.0f, 1.0f, -1.0f - position); mesh.obj.AddComponent<GetSelected>(); mesh.obj.AddComponent<AdditionnalProperties>(); mesh.obj.GetComponent<AdditionnalProperties>().ID = currentID + 1; }
/// <summary> /// adds an existing element in the constructed list /// </summary> /// <param name="mesh"></param> public void AddExistingElement(MyMesh mesh) { constructedElements.Add(mesh); }