x


Alpha on a GameObject?

Is it possible to define the master visibility of a GameObject/mesh renderer? I am vaguely aware that fading a mesh out can be done by getting its material and changing the alpha value of it. However, perhaps my Blitz Basic 3D legacy has spoilt me with this feature, but I like the idea of an object opacity variable. Is there anything like this in Unity? For example, if I have a hypothetic complex object with dozens of materials it seems clumsy getting them all and fiddling with the alpha.

Is there a much better way to fade out a mesh that I am overlooking?

more ▼

asked Nov 20 '09 at 12:45 AM

Novodantis 1 gravatar image

Novodantis 1
1.7k 14 22 40

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You could write a script with a single opacity variable and code that iterates through the materials of the game object it's attached to (e.g. via renderer.materials) and adjusts the alpha of each one.

more ▼

answered Nov 20 '09 at 07:55 AM

technicat gravatar image

technicat
1.5k 10 11 34

I should probably add for the benefit of others seeking this, that it took me a while to realise you need to use a Transparent shader (either one of your own or one in the "Transparent" grouping) for the object's material. Correct me if I'm wrong here.

May 15 '10 at 06:11 PM Novodantis 1
(comments are locked)
10|3000 characters needed characters left

technicat is right, this is the way to go.

When you're there, you might also consider using the two pass transparency shader to get rid of the overlapping polygons artifacts.

more ▼

answered Nov 20 '09 at 08:53 AM

robert gravatar image

robert ♦
1.1k 3 7 27

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2083

asked: Nov 20 '09 at 12:45 AM

Seen: 7576 times

Last Updated: Nov 20 '09 at 12:45 AM