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 Silx · Jan 16, 2011 at 01:48 AM · meshmousecolorpropertiespointer

Get mesh name with mouse click, then change color (and other properties) of mesh

Sorry about the lengthy title.. but that's about the gist of what I'm looking for.

Judging by the 'related questions' thingy that popped up, I may be able to find the mesh color change code from another post.. but I don't see anything about getting a mesh using the mouse pointer.

Any ideas? rifles through more unity docs

Comment
Add comment · Show 1
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 Silx · Jan 23, 2011 at 07:52 PM 0
Share

Still looking for assistance with this. Trying to select a single mesh of a model with the mouse pointer, then change the color of said mesh.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by cjmarsh · Jan 16, 2011 at 02:37 AM

You could use Monobehaviour.OnMouseEnter and OnMouseExit. The script reference page is here. Also, a good resource for searching through unity-related docs is the Custom Google Search.

Comment
Add comment · Show 1 · 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 Silx · Jan 23, 2011 at 07:50 PM 0
Share

I tried attaching both of those to a mesh, and it doesn't seem to do anything. Don't I need to cast a ray at a collider or something to get it to recognize that the mouse is over it?

avatar image
0

Answer by lodendsg · Sep 11, 2012 at 08:13 PM

Based on cjmarsh pointer I came up with the following thought I would post it here in case others came looking for similar.

Note I capture the start color but you could in most cases assume that a mats base color is white I suppose I have a few points where I am using the mat color to tent my meshes so I needed to know what it was before the mouse entered. As to the boolean testing; unnecessary to stack them like that its done for clarity in this case.

 using UnityEngine;
 using System.Collections;
 
 public class MouseEventHandler : MonoBehaviour {
     
     private Color StartColor;
     public Color MouseOverColor = Color.yellow;
     
     // Use this for initialization
     void Start () 
     {
         if(renderer != null)
             if(renderer.material != null)
                 StartColor = renderer.material.color;
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     
     void OnMouseEnter()
     {
         if(renderer != null)
             if(renderer.material != null)
                 renderer.material.color = MouseOverColor;
     }
     
     void OnMouseOver () 
     {
         
     }
     
     void OnMouseExit()
     {
         if(renderer != null)
             if(renderer.material != null)
                 renderer.material.color = StartColor;
     }
 }
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

1 Person is following this question.

avatar image

Related Questions

How to Make Imported MagicaVoxel 3D Object Flash White 0 Answers

Change mesh color with shader or Mesh.colors? 1 Answer

can anybody help with script that takes webcam texture pixel information to deform mesh vertices? 0 Answers

Select object with mouse and hide its children with key, 2 Answers

Render mesh by specifying color of triangle 1 Answer


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