Exemplo n.º 1
0
    public void StartPreview(Piece piece)
    {
        previewParent.DestroyAllChildren();

        currentPiece = piece;
        previewParts = new Transform[piece.parts.Length];
        MaterialPropertyBlock block = new MaterialPropertyBlock();

        for (int i = 0; i < previewParts.Length; ++i)
        {
            previewParts[i] = Instantiate(piece.parts[i].gameObject, previewParent).transform;
            Renderer partRenderer = previewParts[i].GetComponent <Renderer>();
            partRenderer.GetPropertyBlock(block);
            block.SetColor(Color, ColorController.GetPiecePreviewColor(piece.id));
            partRenderer.SetPropertyBlock(block);
        }

        isPreviewing = true;
    }