Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 claudymauzzz1989 · Dec 26, 2013 at 08:16 PM · objectinvisiblehover

Trying to make an object invisible while hovering..

hey there, me and a mate are trying to make an object invisible just while hovering, there must be a mistake in the code. we tried our best but we did not figure it out.

please help! thanks a lot!!!

ps.: the 0f actually should be changed into a 0.5f but it doesn't work either... it should be only slightly invisible

 using UnityEngine;
 using System.Collections;
 
 public class Invisible : MonoBehaviour
 {
     private Color initialColor; 
 
     void Start()
     {
         initialColor = renderer.material.color;
     }
     
     void OnMouseOver()
     {
         renderer.material.color = new Color(initialColor.r, initialColor.g, initialColor.b, 0f);
     }
 
     void OnMouseExit()
     {
         renderer.material.color = initialColor;
     }
 }
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DaveA · Dec 26, 2013 at 08:20 PM

Make sure there is a Collider (or RigidBody) on the object. Can be 'trigger' if you don't want to actually collide with it.

Comment
Add comment · Show 2 · 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
avatar image claudymauzzz1989 · Dec 26, 2013 at 08:31 PM 0
Share

I got a box collider arround it... and it is triggered... but it doesn't work either :(

avatar image DaveA · Dec 26, 2013 at 08:39 PM 0
Share

Then see robertu's answer, probably need a Transparent shader.

avatar image
0

Answer by robertbu · Dec 26, 2013 at 08:28 PM

Your code looks fine. Best guess is that this is a shader issue. Your code will only work if the shader supports transparency and has a main color attribute. As a starting point, use the Transparent/Diffuse shader. And as @DavidA indicates, the object must have a collider, and that collider must be topmost. If you have other colliders in the way, it will not work.

Comment
Add comment · Show 10 · 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
avatar image claudymauzzz1989 · Dec 26, 2013 at 08:39 PM 0
Share

actually I answered allready :D well ok... I got a box collider and it is triggered. if I am using the transparent/duffuse shader it will be invisible right from the beginning... I don't want it to be invisible all the time :)

avatar image DaveA claudymauzzz1989 · Dec 26, 2013 at 08:40 PM 0
Share

$$anonymous$$ake sure the initial alpha value is non-transparent

avatar image claudymauzzz1989 claudymauzzz1989 · Dec 26, 2013 at 08:43 PM 0
Share

how am I changing this?

avatar image robertbu · Dec 26, 2013 at 08:55 PM 0
Share

Using the Transparent/Diffuse should not have the object invisible from the start unless you've edited the color in the material in the Inspector. It will be dark unless you have a light shining on your surface. As a test, do:

Game Object > Other > Directional Light

But it sounds to me like you want a unlit shader with alpha. The one I use came with another package, so I cannot post it, but the Unity Wiki has this shader which should do the job:

http://wiki.unity3d.com/index.php/AlphaSelfIllum

avatar image claudymauzzz1989 · Dec 26, 2013 at 09:05 PM 0
Share

alt text

11.png (357.1 kB)
avatar image claudymauzzz1989 · Dec 26, 2013 at 09:06 PM 0
Share

alt text

1111.png (385.4 kB)
avatar image claudymauzzz1989 · Dec 26, 2013 at 09:07 PM 0
Share

and the alpha value is on 255

Show more comments

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.

Follow this Question

Answers Answers and Comments

19 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Object Invisible from sideview 1 Answer

Is there another way to hide an object 2 Answers

Invisible objects renderer disable? How to stop this? 0 Answers

Having an Invisible Object that Casts Realtime Shadows. 4 Answers

Make and object invisible while in motion? (3d) 2 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