Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Why isn't my pixel reading script working?

$
0
0
I've got this script that should be reading the color of a pixel on the screen but it never returns the right result. For example; it will return black even though there's a giant white object on screen. What am I doing wrong? Here's the code: #pragma strict var colorOfPixel1 : Color; var tex2D : Texture2D; function ReadScreen() { tex2D = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); yield WaitForEndOfFrame(); tex2D.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); tex2D.Apply(); colorOfPixel1 = tex2D.GetPixel(0, 0); } function Start() { } function Update() { ReadScreen(); }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



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