|
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
(comments are locked)
|
|
FIXED: The for loop conditional operator should have been <= not < it was the classic off-by-one error....FACEPALM!
(comments are locked)
|



thanks for fixing the formatting