Hi, I am currently learning how to use unity and I am learning how to make a puzzle piece game. I have stored all the pieces in an array and have labeled them. But now I don’t know how to actually texture each piece individually. Here is my code so far:
using UnityEngine;
using System.Collections;
public class renderTexture : MonoBehaviour
{
private GameObject[] blocks = new GameObject[15];
void Start()
{
Texture image = (Texture2D) Resources.Load("Cuzz", typeof(Texture));
blocks[0] = GameObject.FindGameObjectWithTag("Cube01");
blocks[1] = GameObject.FindGameObjectWithTag("Cube02");
blocks[2] = GameObject.FindGameObjectWithTag("Cube03");
blocks[3] = GameObject.FindGameObjectWithTag("Cube04");
blocks[4] = GameObject.FindGameObjectWithTag("Cube05");
blocks[5] = GameObject.FindGameObjectWithTag("Cube06");
blocks[6] = GameObject.FindGameObjectWithTag("Cube07");
blocks[7] = GameObject.FindGameObjectWithTag("Cube08");
blocks[8] = GameObject.FindGameObjectWithTag("Cube09");
blocks[9] = GameObject.FindGameObjectWithTag("Cube10");
blocks[10] = GameObject.FindGameObjectWithTag("Cube11");
blocks[11] = GameObject.FindGameObjectWithTag("Cube12");
blocks[12] = GameObject.FindGameObjectWithTag("Cube13");
blocks[13] = GameObject.FindGameObjectWithTag("Cube14");
blocks[14] = GameObject.FindGameObjectWithTag("Cube15");
blocks[0].renderer.material.mainTexture = image;
}
void Update()
{
}
}
Cuzz is the name of the image I am trying to put on.