Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BuildingTexture : MonoBehaviour {
- private float colorStep = 3/128; // 1/(256/6) this*42 is nearly 1
- private Color tempColor = new Color (1,0,0,1);
- public Texture2D tex = new Texture2D (256, 256);
- // Use this for initialization
- void Start () {
- renderer.material.mainTexture = tex;
- for (int x=0; x<=42; x++) { //42 steps in each for loops
- tempColor.g = tempColor.g+colorStep;
- drawLine(x,tempColor);
- }
- for (int x=43; x<=84; x++) {
- tempColor.r = tempColor.r-colorStep;
- drawLine(x,tempColor);
- }
- for (int x=85; x<=127; x++) {
- tempColor.b = tempColor.b+colorStep;
- drawLine(x,tempColor);
- }
- for (int x=128; x<=170; x++) {
- tempColor.g = tempColor.g-colorStep;
- drawLine(x,tempColor);
- }
- for (int x=171; x<=212; x++) {
- tempColor.r = tempColor.r+colorStep;
- drawLine(x,tempColor);
- }
- for (int x=213; x<=256; x++) {
- tempColor.b = tempColor.b-colorStep;
- drawLine(x,tempColor);
- }
- tex.Apply();
- Debug.Log (tex);
- }
- void drawLine(int x, Color tempColor){
- Debug.Log(tempColor);
- for (int y=0; y<256; y++) {
- tex.SetPixel (x, y, tempColor);
- }
- }
- // Update is called once per frame
- void Update () {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement