Hello people,
I wonder if it is possible for Unity to scan each pixel of an image. If so, could I say: “On red pixel do this” “On blue pixel do that” … ?
I’m a Unity Beginner, so does someone have a little help maybe? ![]()
Thank you very much!
olop
Hello people,
I wonder if it is possible for Unity to scan each pixel of an image. If so, could I say: “On red pixel do this” “On blue pixel do that” … ?
I’m a Unity Beginner, so does someone have a little help maybe? ![]()
Thank you very much!
olop
You sure can!
A little more help from the peanut gallery for ya… Check out the Texture2d class… specifically the GetPixel and SetPixel functions
http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.html
Thanks for the help so far! I managed to get the GRBA values out of where I point the mouse. But if I reach a certain y value with the mouse, the RGBA won’t show correct. I tried to find the error but I can’t seem to manage it.
Maybe someone could have a short look, it’s only a test file with a picture and about 10 lines of code - I don’t know where the error lies (maybe it’s only my screen and it works for you?)
Would be really happy if someone has a tip for a noob! ![]()
Here you can find the project:
http://dl.dropbox.com/u/29494006/unity/getpixel.rar
The error lied in choosing the image type as “advanced” while importing. The right way to do it was choosing “GUI”.
I don’t know why this caused this strange bug either - but it’s gone now.
Here is a really good example of using an image as a way of specifying a map. It should help you grease the head wheels and isn’t complicated at all.
Thank you really much for posting this example - I’ll have a look into it tommorrow! ![]()