问题描述:

I have a unity application. When the user hover on the object, I want to change mouse image.So, I want to know how to make part of image transparent in unity3d? If I use directly .png image, the mouse looks like below image :

I don't want to show gray area. How can I do?

网友答案:

An image file can be saved with a crowd of formats. For your arrow can have transparent areas you should save it in a format that handles the so-called "alpha channel". This channel stores information about the degree of transparency (from 0% to 100%) of all and each of the pixels. Simple programs like Windows Paint eliminate this channel. I recommend you use "Gymp", is the one I use (It's free)

If you don't have that problem. Be sure you have selected the correct Shader Type. Not all the shaders are ready to transparency. I recomend you to use the "transparent Cutout" for 3D Objects:

And "Sprite (2d and UI)" for 2D Objects:

网友答案:

In Unity, in the asset explorer, if you click on your .png image, you should be able to select the texture type. It is definitely possible to have textures with transparency. You should also simple check that you saved your png image with transparency

网友答案:

Transparency shows black when using a non transparent shader so that is not your case. Your image seems to be a jpg so it has no transparency (RGB only).

Unity does not use jpg and converts them to png but as the original has no transparency anyway, it is white pixels in the original and white pixels in the png conversion.

You need to rework the image in Gimp or Photoshop to remove the useless grey parts and make sure you save it as png so the transparency is stored (RGBA).

相关阅读:
Top