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 /
This question was closed Jun 09, 2013 at 01:50 PM by fafase for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by DricoJD · Jun 08, 2013 at 02:00 PM · sceneloadlevelonmouseenter

Loading Scene on a series of events

Hello people of Earth and Mars.

I am making my Game Menu - I am actually making it to improve my knowledge on scripting so far I am doing great! However I have ran into a problem that the internet has no answer for and I have spent about 6 hours straight and still can not find an answer for.

So here is my problem:

I want a level/scene ("MainTerrainScene") to be loaded when a series of events happen. In this case the series of events are. When the cursor (DefaultMouse) Enters the text "New Game" (Box Collider : 3D Text) and whilst inside the text you click the left mouse button; A new scene called "MainTerrainScene" will be loaded.

I have tried everything I know of and the script works fine when the function is update and not "OnMouseEnter" however therefore the cost of not having the mouse to enter and then click is paid.

Here is my current script:

 function OnMouseEnter()
 {
     if 
     
     (Input.GetMouseButtonDown(0)) 
     
     {
                 Application.LoadLevel("MainTerrainScene");
         
         
     }
         
 }


The Code is in JavaScript.

Thanks for your time in reading hopefully you will have an answer for me :)

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

  • Sort: 
avatar image
1
Best Answer

Answer by fafase · Jun 08, 2013 at 02:58 PM

Your 3D text has a colliderso you can use Raycast and Input.GetMouseButton(0)

http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html

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 DricoJD · Jun 09, 2013 at 08:07 AM 0
Share

Works, Thanks

avatar image
1
Wiki

Answer by GabrielSmith · Jun 08, 2013 at 02:35 PM

Why don't you use the OnMouseDown function to load the scene? This function is called when the mouse clicks over a Collider or a GUI, exactly what you want:

 function OnMouseDown () {
 Application.LoadLevel("MainTerrainScene");
 }
Comment
Add comment · Show 3 · 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 DricoJD · Jun 08, 2013 at 02:56 PM 0
Share

I will thumb this up, however it is not what I am looking for. I know what you mean, but it would mean making a new script as all the inputs are attacched in one script

avatar image GabrielSmith · Jun 09, 2013 at 01:16 AM 0
Share

You wouldn't need to create another script. Just change the On$$anonymous$$ouseEnter function to On$$anonymous$$ouseDown and when you click over the object, the scene will be loaded.

@Edit: Oh, I guess i understand what you said. You have only one script, and using On$$anonymous$$ouseDown would need to create other script. But the same applies to On$$anonymous$$ouseEnter. You'll have to do what the bellow comment says: use Raycast and InputGet$$anonymous$$ouseButton(0).

avatar image DricoJD · Jun 09, 2013 at 08:06 AM 0
Share

Thanks for helping anyway :)

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

Load Scene 1 Answer

Random level select 1 Answer

Input.GetMouseButton on multiple objects 1 Answer

Load level after Image Sequence 0 Answers

Need to link a button to next level 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