- Home /
My grid is getting created on the wonk
I have tried to debug this but I honestly cant see anything wrong with it, I was wondering if anybody can help.
Basically what it does is process a 64x64 pixel texture and deletes sections of a grid based on the luminance of each pixel, I am in the process of revamping my code and all was going well until I reached this bit, I cant see why it would be making my grids come out with a diagonal slant as if each iteration was offsetting by one unit to the right.
heres what it looked like right in the obsolete code
and here is it in the new code
using UnityEngine; using System.Collections; using System.Collections.Generic;
public class NoiseProcessor : MonoBehaviour {
public Texture2D noiseTex;
public static Color[] pxList = new Color [4096];
// INIT
void Start ()
{
pxList = noiseTex.GetPixels();
TextureTranslator();
}
//CubeGrid.GridArray[i].gridColumn[i].name
void TextureTranslator(){
int counter = 0;
for ( int row = 0; row < 63; row++ ){
for (int col = 0; col < 63; col++ ){
//Debug.Log(row + "_" + col);
if(isNotBlack(counter)){
Cube.destroyBlock((GameObject)CubeGrid.GridArray[row].gridColumn[col].gameObject);
}
Debug.Log(counter + " " + pxList[counter].grayscale);
counter++;
}
}
}
// is not black fuction ~ returns bool
bool isNotBlack(int i){
if(pxList[i].grayscale <= 0.3){
return false;
} else {
return true;
}
}
}
Answer by sacredgeometry · Aug 10, 2011 at 01:02 PM
FIXED: The for loop conditional operator should have been
Your answer
Follow this Question
Related Questions
Method containing while loop in custom class? 1 Answer
why does "new GameObject" creates 2 emptys 1 Answer
What is the problem in my script? 2 Answers
Is this loop infinite? 2 Answers
list.contains isn`t working 1 Answer