简体   繁体   English

Unity3d更改Texture2D颜色

[英]Unity3d change Texture2D color

In Unity3d, how to change Texture2D color to black and white.....I am using unity 5, bew UI Canvas, for ImageUI Texture want to change color black and white.. 在Unity3d中,如何将Texture2D颜色更改为黑色和白色.....我正在使用unity 5,bew UI Canvas,因为ImageUI Texture想要更改颜色为黑色和白色。

I tried with texture.SetPixels(); 我尝试使用texture.SetPixels(); and getPixelsbilliner(); getPixelsbilliner(); as per link . 按照链接

Thanks, Adi. 谢谢阿迪

This might do the trick. 这可能会成功。

void Start() {
    GetComponent.<Renderer>().material.mainTexture = Texture2D.blackTexture;
}

use 采用

myImageCompenent.material.color = wantedColor;

this sets an image color, just as you see in the editor. 就像在编辑器中看到的那样,这将设置图像颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM