Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 mrdoktor1974 · Oct 04, 2011 at 06:02 PM · materialcolorrendereralphaclone

Renderer.material not cloning?

I have a prefab which I would like to fade out the alpha on without fading out the alpha on all objects with that material. In the documentation it says the material should be cloned once changed but it's doesn't seem to do that in my project. I'm developing for Android, should that make any difference?

 if (a > 0.0)
 {
     a = a - 1.0/30.0;
     object.renderer.material.color.a = a;
 }
 else
 {
     Destroy(gameObject);
 }
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

3 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by mrdoktor1974 · Oct 05, 2011 at 08:05 AM

I found the problem. Both of my objects acted as if clicked because I was using an examplescript that wasn't specific to one object. ()

Have you got any good example of how to track if an item is "touched". I tried using RaycastHit but the variables "collider" and "rigidbody" is empty in the debugger.,My script is definitely entering the if statement, because it fades out all instances of the prefab. I'm not calling renderer.sharedMaterial, I'm calling renderer.material.

After clicking one of my objects both get (Instance) after the material name.

Now I'm starting to think that both objects pick up the click (touch).

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

Answer by mrdoktor1974 · Oct 05, 2011 at 08:05 AM

My bad. I was using an example that wasn't intended for this kind of function. So whenever a Raycast hit an object all my prefabs acted as if clicked.

Have you got any examples of clicking/touching objects? I've tried using RaycastHit but the variable collider return null.

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

Answer by loopyllama · Oct 05, 2011 at 06:15 AM

renderer.material will instance a material and break any possible batching while renderer.sharedMaterial will not.

for your specific case, either it is a material instance and you haven't realized it (check the material on the object during gameplay for the Instance text next to the material name in the Inspector) or your script is not getting inside the "if" statement and thus not creating a material instance.

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Changing two different objects renderer colour 1 Answer

Fade out a material that has a texture 1 Answer

Material doesn't have a color property '_Color' 4 Answers

How to Make a Character Flicker? 1 Answer

Can't animate Material.Color properties 3 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