• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by blender51 · Sep 25, 2012 at 04:36 PM · transparencyalphafade

Fading out a transparent material

Usually, the answer to t$$anonymous$$s question is "Use a transparent shader", but I don't t$$anonymous$$nk I'm so lucky. :\ I've tried t$$anonymous$$s code with both the Transparent/Diffuse and Unlit/Transparent shaders. I've also copy-pasted some solutions I found online, but none of them worked.

The GameObject is a small plane with a texture that's used to show "You can move to t$$anonymous$$s tile", and after the move, it's meant to fade out. It works perfectly when I make it remove itself, but the fading doesn't work at all. To simplify t$$anonymous$$ngs, I'm trying to make it set itself to 0.05 alpha w$$anonymous$$le it's alive. Once I get that part, doing a fade will be simple math.

Not sure that it matters, but the texture itself is an RGB png (no alpha channel yet), and the GameObject was instantiated from a prefab. I checked the instantiated objects w$$anonymous$$le in-game, and all their settings looked fine... same transparent shader, correct variables...

Any help will be greatly appreciated :D

pragma strict

var binIchBrauchte : int = 1; var sollIchSc$$anonymous$$mmern : int = 1; var meinAlpha : float = 1; var posTile : Vector2;

var guiObject : Material; var fadeTime = 1.0; enum Fadee {In, Out}

function Start () { binIchBrauchte = 1; gameObject.tag = "TileBorder"; guiObject = renderer.material; }

function Update () { //guiObject = gameObject.renderer.material; if (binIchBrauchte == 0) { // Fade out, and then destroy myself // Kills the game object Destroy (gameObject); } else if (binIchBrauchte == 1) { if (sollIchSc$$anonymous$$mmern == 1) { // Alpha channel gameObject.transform.renderer.material.color.a = 0.05; gameObject.renderer.material.color.a = 0.05; transform.renderer.material.color.a = 0.05; renderer.material.color.a = 0.05; } }

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Screenhog · Sep 25, 2012 at 04:43 PM 0
Share

Well, I might as well get the basic out of the way first... if you go into the material itself, open the color, and edit the alpha channel, does the material fade?

avatar image blender51 · Sep 25, 2012 at 04:56 PM 0
Share

How do I do that? I see the material, but I don't see any "color" settings...

avatar image Screenhog · Sep 25, 2012 at 05:11 PM 0
Share

In Transparent/Diffuse, the first setting is "Main Color". There will be a rectangle to the right (probably white). Click that, and slide the "A" value back and forth.

avatar image blender51 · Sep 25, 2012 at 05:22 PM 0
Share

Ah, I was in Unlit/Transparent. I tried Transparent/Diffuse, and the code works now.

Tbh, I'm not sure what happened, because I tried Transparent/Diffuse right before posting this question. I did simplify the code a bit, so maybe I had an error when I tested.

Sorry to waste your time - I guess the solution really WAS "use a transparent shader" :P

avatar image blender51 · Sep 25, 2012 at 05:23 PM 0
Share

Also, if you copy-paste your comment as an answer, I'll choose it as the answer. Thanks for the help! :D

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Screenhog · Sep 25, 2012 at 05:37 PM

In Transparent/Diffuse, the first setting is "Main Color". There will be a rectangle to the right (probably w$$anonymous$$te). Click that, and slide the "A" value back and forth.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Fading out doesn't fade out, but instantly goes from black to clear 0 Answers

Fading all but single instance of a button 1 Answer

Fade In/out issue about a gameobject 0 Answers

Shader is not displaying alpha correctly 0 Answers

Alpha not displaying when changed in code, unless changed manually in the inspector 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges