最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - Set two overlapping 2D GameObjects with Images attached to half-opacity as if it were a single image - Stack Overflow

programmeradmin0浏览0评论

I will refer to these three images to aid the explanation this question.

Suppose I have two GameObjects in Unity 2D, both with Image components attached. Further suppose that one of the GameObjects overlaps the other in the scene space. This is illustrated in the first, leftmost image with a blue triangle above a red circle. The checkerboard background represents whatever else is in the scene, rendered partially underneath the red circle and blue triangle.

If I were to set the opacity of both of the GameObjects to 0.5 (that is, their Color is set to Color(1.0, 1.0, 1.0, 0.5)), something like the second, middle image would be the result. There is a purple image where you can see the red circle through the blue triangle.

I do not want this. I instead want to create the effect as seen in the third, rightmost image, it is if the two images were combined into a single image, and then their opacity was set to 0.5.

How can I do this?

I would also like to extend this to an arbitrary number of overlapping images, not just two.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论