# Fading objects (413329)

**URL:** https://discussions.unity.com/t/fading-objects-413329/413329
**Category:** Scripting
**Tags:** Scripting
**Created:** [May 7, 2010, 5:34pm UTC](https://discussions.unity.com/t/fading-objects-413329/413329 "2010-05-07T17:34:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_61482172](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@anon\_61482172](https://discussions.unity.com/u/anon_61482172)
#### Post date: [May 7, 2010, 5:34pm UTC](https://discussions.unity.com/t/fading-objects-413329/413329/1 "2010-05-07T17:34:10Z")

</div>

Hey guys,

I’ve done some hunting through the forum and eleswhere and for whatever reason (newbie-ism, most likely) I can’t get a script to work.

What I’m attempting to do is fade an object out once an input key is hit. I have everything else setup and working (meaning the triggers, inputs, IF statements, etc)…it’s the changing the material once that IF statement becomes True.

I’ve seen that I need to use a Transparent shader, but how is that tied to the Alpha that the sample scripts I’ve seen call? Basically…what am I missing??

Thanks for any help,  
Chris

---

<div class="post-metadata">

### Author: ![Eric5h5](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/eric5h5/32/44225_2.png) [@Eric5h5](https://discussions.unity.com/u/Eric5h5)
#### Post date: [May 7, 2010, 5:44pm UTC](https://discussions.unity.com/t/fading-objects-413329/413329/2 "2010-05-07T17:44:10Z")

</div>

Have a look at [this](http://www.unifycommunity.com/wiki/index.php?title=Fade) fade script on the wiki.

–Eric

---

<div class="post-metadata">

### Author: ![anon\_61482172](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@anon\_61482172](https://discussions.unity.com/u/anon_61482172)
#### Post date: [May 7, 2010, 5:56pm UTC](https://discussions.unity.com/t/fading-objects-413329/413329/3 "2010-05-07T17:56:02Z")

</div>

I’ve been all over that entry and again, it’s probably just ignorance, but I still can’t make it function.

I copied the large script at the bottom and place it into my scene, but I get the error BCE0018: The name ‘Fade’ does not denote a valid type.

Are there some generic calls that I need to swap out some code to make it jibe with my scene?

Again, I apologize about the uber newbieness of this.

Thanks for your help.

---

<div class="post-metadata">

### Author: ![anon\_61482172](https://avatars.discourse-cdn.com/v4/letter/a/e9bcb4/32.png) [@anon\_61482172](https://discussions.unity.com/u/anon_61482172)
#### Post date: [May 7, 2010, 9:03pm UTC](https://discussions.unity.com/t/fading-objects-413329/413329/4 "2010-05-07T21:03:00Z")

</div>

Ok…It finally clicked and I was able to get everything working.

Next question is about that Fade.js. Where is it in the code so that I can kill the ‘return’ to the original color? Basically to have to only perform half the cycle.

Thanks…

---

<div class="post-metadata">

### Author: ![Eric5h5](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/eric5h5/32/44225_2.png) [@Eric5h5](https://discussions.unity.com/u/Eric5h5)
#### Post date: [May 7, 2010, 9:34pm UTC](https://discussions.unity.com/t/fading-objects-413329/413329/5 "2010-05-07T21:34:04Z")

</div>

It doesn’t actually return to the original color at all, depending on what method you’re using.

```auto
// Fade out, from 1.0 to 0.0, over 3 seconds
Fade.use.Alpha(renderer.material, 1.0, 0.0, 3.0);

```

–Eric
