public PhysicalObject Clone() { PhysicalObject po = (PhysicalObject)MemberwiseClone(); po.visualSet = new List <VisualSetLOD>(); po.Reset(); for (int i = 0; i < visualSet.Count; i++) { VisualSetLOD l = new VisualSetLOD(); l.LODdistance = visualSet[i].LODdistance; l.off_data = visualSet[i].off_data; l.obj = visualSet[i].obj.Clone(); po.visualSet.Add(l); if (l.obj is MeshObject) { MeshObject m = ((MeshObject)l.obj); if (m.name != "Mesh") { po.Gao.name = "[PO] " + m.name; } m.gao.transform.parent = po.Gao.transform; } } if (collideMesh != null) { po.collideMesh = collideMesh.Clone(); po.collideMesh.gao.transform.parent = po.Gao.transform; } MapLoader.Loader.physicalObjects.Add(po); return(po); }
public PhysicalObject Clone() { PhysicalObject po = (PhysicalObject)MemberwiseClone(); po.visualSet = new VisualSetLOD[visualSet.Length]; po.Reset(); for (int i = 0; i < visualSet.Length; i++) { po.visualSet[i].LODdistance = visualSet[i].LODdistance; po.visualSet[i].obj = visualSet[i].obj.Clone(); if (po.visualSet[i].obj is MeshObject) { MeshObject m = ((MeshObject)po.visualSet[i].obj); m.Gao.transform.parent = po.Gao.transform; } } if (po.visualSet.Length > 1) { float bestLOD = po.visualSet.Min(v => v.LODdistance); foreach (VisualSetLOD lod in po.visualSet) { if (lod.obj.Gao != null && lod.LODdistance != bestLOD) { lod.obj.Gao.SetActive(false); } } } if (collideMesh != null) { po.collideMesh = collideMesh.Clone(); po.collideMesh.Gao.transform.parent = po.Gao.transform; } return(po); }