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 Hydraxia · Apr 14, 2013 at 12:49 PM · menu

Simple Menu Script

Hello! I want to make a simple menu script,i watched/read some tutorials, but i don't understand what is the problem. Here is the code:

  using UnityEngine;
         using System.Collections;
         
         public class Menu_Exit : MonoBehaviour {
             
             public bool isMenu_Exit = false;
             
             void OnMouseEnter()
             {
                 renderer.material.color = Color.green;
             }
             
             void OnMouseExit()
             {
                 renderer.material.color = Color.black;
             }
             
             void OnMouseDown()
             {
                     Application.Quit();
             }
         }



I have a mesh and this. When i start the application, nothing works. No color change, the application doesn't closes.

I probed to write ''if'' after the void OnMouseDown(), not works.

Thank you!

Comment
Add comment · Show 10
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 dorpeleg · Apr 14, 2013 at 01:06 PM 0
Share

Do you have a collider on the gameobject?

avatar image Hydraxia · Apr 14, 2013 at 01:17 PM 0
Share

Yes, i added a box collider. But why i need collider? $$anonymous$$y mouse only has 2 axes, not 3 ( because this is a 3D menu ) This is problem?

avatar image EpicGamer928 · Apr 14, 2013 at 01:24 PM 0
Share

I know a way to do a menu with 3d text in Unity. Do you want the script?

avatar image Hydraxia · Apr 14, 2013 at 01:29 PM 0
Share

It would be great!

avatar image dorpeleg · Apr 14, 2013 at 01:50 PM 0
Share

Are you running this in the inspector? I think Application.Quit() doesn't work when running in the inspector.

The on$$anonymous$$ouse functions don't work on IOS if that's what you are trying.

Other then that, it should work.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by PadExe · Aug 03, 2017 at 06:00 PM

@Hydraxia the reason that nothings works is that you have no connection between any UI element (Text, Buttons etc.) and one of your functions. If you want to do this you have to create some UIElements and connect it with your script.

You can do this when you first initialize your Element 1. First write at the top : using UnityEngine.UI; 2. then for example public Text (type of the UI) text (name of your UI) 3. : if (Input.GetKeyDown(Keycode.Space) { Application.Quit(); }

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 ShadyProductions · Aug 03, 2017 at 06:03 PM 0
Share

Please don't bump up post from 4 years ago.

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

14 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Problem with Pause and Pause Menu Script 1 Answer

[Newbie] Simple Menu script c# 1 Answer

When do we need to use Class? 1 Answer

how to create Magnetic repulsion ? 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