Beispiel #1
0
 // 画矩形
 public void DrawTileRect(BlockTile tile)
 {
     if (tile.drawRect == null)
     {
         MyDrawRect drawRect = GetFreeDrawRectObj();
         drawRect.SetGreenRectInfo(tile.size);
         drawRect.transform.parent        = tile.img.transform;
         drawRect.transform.localPosition = new Vector3(0, -tile.size.y / 2);
         drawRect.transform.localScale    = Vector3.one;
         drawRect.SetRectColor(new Color(0, 1, 0, 0.2f));
         tile.drawRect = drawRect;
     }
 }
Beispiel #2
0
    // 回收池
    MyDrawRect GetFreeDrawRectObj()
    {
        MyDrawRect drawRect = null;

        if (drawPool.Count > 0)
        {
            drawRect = drawPool[drawPool.Count - 1];
            drawPool.RemoveAt(drawPool.Count - 1);
        }
        else
        {
            GameObject obj = new GameObject("draw");
            drawRect = obj.AddComponent <MyDrawRect>();
        }

        return(drawRect);
    }
Beispiel #3
0
 // 加入回收
 void RecycleDrawRectObj(MyDrawRect rect)
 {
     drawPool.Add(rect);
     rect.transform.SetParent(drawRectPoolObj.transform);
 }