title: Unity3D looking for setPixels example to paint with texture in C#
body: <p>I need to find a way that allow me to paint a gameObject using a texture, the goal is to make a clone of <a href="http://www.youtube.com/watch?v=yc-CHYcnwkk" rel="nofollow noreferrer">this game</a> </p>
  
  <p>I already thought that i can fake the painting feature by using depthMask solution which i explained <a href="https://gamedev.stackexchange.com/questions/69173/theoretical-solution-for-drawing-with-mask?">here</a>, 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 ?</p>
  
  <p>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. </p>
  
  <p>Thank you</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>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)</p>
  
  <pre><code>// 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&lt;tmpTexture.height; y++) {
                      for (int x = 0; x&lt;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;
  
  
      }
  </code></pre>
  
  <p>Now i think that the problem will only be, "how to know which pixel i should replace based on mouse position over the object"</p>