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 thenachotech1113 · Jun 01, 2012 at 01:21 AM · guitextmouserenderermultiple-choice

Hey, i need help with GUI text ibn javascript

hey, Im making a code for a multiple choise question but for some reason when i drag the mouse over it , it does change coler but when i click, it does not, what could be going on?

pragma strict

var correct = true; var answer = true; var wrong = false; var locking = false;

 function Start () {
 Screen.lockCursor = true;
 }
 
 function Update () {
 Screen.showCursor = false;
 // center mouse   
     if (Input.GetKeyDown(KeyCode.P))
         if (Screen.lockCursor)
         Screen.lockCursor = false;
         
     else{
     Screen.lockCursor = true;
     }
 //if correct
     if (Input.GetButtonDown("fire1")&& answer)
     {
     renderer.material.color = Color.green;
     locking = true;
     }
     if (Input.GetButtonDown("fire1")&& wrong)
     {
     renderer.material.color = Color.red;
     locking = true;
     }
     if (wrong && answer)
     {
     answer = false;
     }
                         
 }
 // change color when mouse is on
 function OnMouseEnter ()
     {
     if (locking = false)
         renderer.material.color = Color.red;
     }
     
 function OnMouseExit ()
     {
     if loking = false;    
         renderer.material.color = Color.white;
     }
 thanks a lot
Comment
Add comment · Show 2
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 sooncat · Jun 01, 2012 at 01:37 AM 0
Share

Dose On$$anonymous$$ouseDown works?

avatar image thenachotech1113 · Jun 01, 2012 at 02:09 AM 0
Share

whell u are right and thank you but the problem is still there

1 Reply

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

Answer by hijinxbassist · Jun 01, 2012 at 02:04 AM

For a click you can use the MonoBehaviour function http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseUpAsButton.html>OnMouseUpAsButton , which on click will change the color when the user releases the button.

 function OnMouseUpAsButton()
 {
     if(correct)renderer.material.color = Color.green;
     else renderer.material.color = Color.red;
 }
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 thenachotech1113 · Jun 02, 2012 at 12:51 AM 0
Share

thanks a lot man

avatar image hijinxbassist · Jun 02, 2012 at 04:12 AM 0
Share

@thenachotech no prob, this is one of those functions that takes ray casting out of the equation. I have never used it :p but i know its there and how handy it can be.

Thanks to the unity dev $$anonymous$$m and their ongoing effort to make ga$$anonymous$$g easier from a game devs POV. One of these days im sure ill need it, for now i just preach it :)

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

6 People are following this question.

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

Related Questions

How can I display text and change color of objects when I roll over them with the mouse? 1 Answer

GUI text Main Menu 1 Answer

Move the text in a GUI Button/Box 1 Answer

GUI.label overlapping text 1 Answer

Disable Selection on Left button Mouse Click 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