Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Error CS1061

$
0
0
So, I'm generating terrain (once again) and I'm getting an error. The error is Assets\Scripts\MapDisplay.cs(21,17): error CS1061: 'Texture2D' does not contain a definition for 'setPixels' and no accessible extension method 'setPixels' accepting a first argument of type 'Texture2D' could be found (are you missing a using directive or an assembly reference?) Here is my code: using System.Collections; using System.Collections.Generic; using UnityEngine; public class MapDisplay : MonoBehaviour { public Renderer textureRender; public void DrawNoiseMap(float[,] noiseMap) { int width = noiseMap.GetLength (0); int height = noiseMap.GetLength (1); Texture2D texture = new Texture2D (width, height); Color[] colourMap = new Color[width * height]; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { colourMap[y * width + x] = Color.Lerp(Color.black, Color.white, noiseMap [x,y]); } } texture.setPixels (colourMap); texture.Apply (); textureRender.sharedMaterial.mainTexture = texture; textureRender.transform.localScale = new Vector3(width,1,height); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>