擦除飞机上的纹理

时间:2012-10-04 08:15:19

标签: unity3d

我有一个纹理应用于一个平面,并希望在屏幕上触摸擦除该平面上的选定位置(如橡皮擦),以便在我触摸的位置,纹理应该是透明的。我怎么能这样做?

1 个答案:

答案 0 :(得分:2)

在上述评论中作出澄清后,这将有效:

Texture2D texture = renderer.material.mainTexture;
Color color = new Color(0.5F, 0.5f, 0.5F, 0.5F);  //example color, grey w/ half opacity

texture.SetPixel(0,0,color); //set pixel (0,0) to the color specified
texture.Apply();  //Must be called at least once after all changes to pixels made

希望这就是你所需要的。显然,您需要添加代码以仅修改光标所在位置附近的像素。