public GameObject InsertPointAt(Transform edge, Vector3 position) { _Block originBlock = edge.GetComponent <_Block>(); int index = blocks.IndexOf(originBlock); _Vertex point = vertexPrefab.Spawn(); points.Insert(index, point); point.transform.parent = transform; point.transform.localRotation = Quaternion.identity; point.transform.position = position; //ition; Vector2 localPosition = point.transform.localPosition; originBlock.SetEndsPosition(localPosition, _vertices[index]); _Block block = edgePrefab.Spawn(); blocks.Insert(index, block); block.transform.parent = transform; block.SetEndsPosition(_vertices[PreIndex(index)], localPosition); _vertices.Insert(index, localPosition); return(point.gameObject); }
public void InitialPoints() { foreach (var pos in InitialVertices) { _Vertex vertex = vertexPrefab.Spawn(); vertex.transform.SetParent(transform); vertex.transform.localPosition = pos; vertex.Border = this; vertexs.Add(vertex); } Face2D face = Shape.AddPoints(vertexs.Select(v => v.Point).ToArray()); face.Name = "BorderFace"; foreach (var e in face.BasicEdges) { _Block block = blockPrefab.Spawn(); block.transform.SetParent(transform); block.Border = this; block.Edge = e; blocks.Add(block); } _lazyAllVertices.isValeChanged = true; }