示例#1
0
    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);
    }
示例#2
0
    private void SpawnPoint(int index)
    {
        Vector2 position = _vertices[index];

//		GameObject pointObj = Instantiate( vertexPrefab) as GameObject;
//		pointObj.transform.parent = transform;
//		pointObj.transform.localRotation = Quaternion.identity;
//		pointObj.transform.localPosition = position;
//
//		_Point point = pointObj.GetComponent<_Point>();
//		points.Add (point);

        _Vertex point = vertexPrefab.Spawn(transform.position, transform.rotation);

        points.Add(point);

        point.transform.parent        = transform;
        point.transform.localRotation = Quaternion.identity;
        point.transform.localPosition = position;

//		GameObject blockObj = Instantiate( edgePrefab) as GameObject;
//		blockObj.transform.parent = transform;
//
//		_Block block = blockObj.GetComponent<_Block>();
//		blocks.Add (block);
        _Block block = edgePrefab.Spawn(transform.position, transform.rotation);

        blocks.Add(block);

        block.transform.parent = transform;

        block.SetEndsPosition(_vertices[PreIndex(index)], position);
    }