public void CreateTexture() { if (grid == null) { grid = GetComponent <TerminalGrid> (); } var texture = new Texture2D(12, 8, TextureFormat.ARGB32, false); for (int i = 0; i < 8; i++) { for (int j = 0; j < 12; j++) { if (j < 2 || j > 9) { texture.SetPixel(j, i, Color.black); } else { if (grid.puzzles[0].Grid[7 - i, j - 2] == 1) { texture.SetPixel(j, i, Color.white); } else { texture.SetPixel(j, i, Color.black); } } } } // set the pixel values texture.filterMode = FilterMode.Point; // Apply all SetPixel calls texture.Apply(); screenModel.GetComponent <Renderer> ().sharedMaterial.mainTexture = texture; }
// Use this for initialization void Start() { grid = GetComponent <TerminalGrid> (); }