How to put specific shapes/textures instead of generating colors (C#)

Hello,

My problem is that I’m making pentomino-like game and I’m generating shapes from matrixes. Code works well, etc. But my problem is to add textures to them (2D plant-shape like figures). Is there any method to hardcode them or is this just wrong from the beginning and I should start with different approach and models of that pentominos?

Right now:

	public void InitBlockTextures(int w, int h) //initializing block textures
	{
		green_texture = new Texture2D(w, h);
		...
		black_texture = new Texture2D(w, h);
		CreateBeveledTexture(green_texture, 0, 1, 0);
		...
		CreateBeveledTexture(black_texture, 0, 0, 0);
	}

	public Texture2D GetBlockTexture(int color) //for each color we're getting texture
	{
		if(color==1)return green_texture;
		...
		if(color==8)return black_texture;
		return null;
	}

I used matrixes and colors generated that way cause it was pretty simple to program rotating options for something like this:

public class PentominoPieces //here we have pieces
{
...
	int[,] P8R1 = new int[4,4]	{
        {1,1,0,0},
        {0,1,1,0},
        {0,0,1,0},
        {0,0,0,0}
	};
...
}

public int[,] GetTetrisPieceBitmask(int type, int rotation) //each rotation has specified bitmask
{
    ...
	if(type==8)
	{
		if(rotation==1)return P8R1;
		if(rotation==2)return P8R2;
		if(rotation==3)return P8R3;
		if(rotation==4)return P8R4;
	}

But now it not looks that easy anymore and I’ll be thankful for every help.

I’m not sure what you want to do (my english are very bad) but if you use a texture you create in script, you can use Texture2D.SetPixel, Texture2D.SetPixels and Texture2D.Apply to change with code your Texture, like said here

Edit: to load your own Texture, you can use Ressources.Load and do something like that:

Texture2D myTexture = Ressources.Load("YourPath/YourTextureName") as Texture2D

The example in the link show how apply directly the Texture on object’s material and said “The path is relative to any Resources folder inside the Assets”.

Hope it could help