I need to find a way that allow me to paint a gameObject using a texture, the goal is to make a clone of this game
I already thought that i can fake the painting feature by using depthMask solution which i explained here, however, after many hours of research it seems that setPixels,setPixel and setPixels32 can be used to create a real painting but For some reason all the setPixels related topics at the Script Reference are in JavaScript, i tried to port it to c# but i always got errors, plus it's kind of a complicated approach and the script reference doesn't explain it very well, So am hoping that anyone can please wrote me an example using setPixels in order to change a part of an object texture using another texture ? or maybe we can set the whole object alpha to 0, and when we click on it, we change a part of that texture alpha to 1 ?
I really hope this topic doesn't get closed because of it's variety, i tried my best to ask a straight forward question while explaining the entire situation.
Thank you
EDIT:
After a couple of hours, i've reached a pretty cool result, and i think that this can be the good way to reach my goal, this script allow to replace a specific pixel in a material texture with another chosen texture (target texture must be in the same size, and readable)
// the texture that i will paint with
public Texture2D targetTexture ;
//temporary texture
Texture2D tmpTexture;
void Start ()
{
//setting temp texture width and height
tmpTexture = new Texture2D (targetTexture.width, targetTexture.height);
for (int y =0; y<tmpTexture.height; y++) {
for (int x = 0; x<tmpTexture.width; x++) {
//filling the temporary texture with the target texture
tmpTexture.SetPixel (x, y, targetTexture.GetPixel (x, y));
}
}
//Apply
tmpTexture.Apply ();
//change the object main texture
renderer.material.mainTexture = tmpTexture;
}
Now i think that the problem will only be, "how to know which pixel i should replace based on mouse position over the object"