Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 $$anonymous$$ · Dec 15, 2014 at 05:44 PM · scene

Problem loading scene on

I am trying to get button to load new scene when clicked but when I click anywhere it happens Here is my code:

  #pragmastrict
  
  functionUpdate () {
  
  if(Input.GetMouseButton(0))
  
  Application.LoadLevel("TEST");
 
 }

Please help

Comment
Add comment · Show 6
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 MrSoad · Dec 15, 2014 at 05:46 PM 0
Share

Yep what @tanoshimi said, so busy looking at your functionUpdate I never saw the rest of the problem :D

avatar image taxvi · Dec 15, 2014 at 05:49 PM 0
Share

I think he wants to load the level on the buttonClick event, not on mouseDown event

avatar image Fran-Martin · Dec 15, 2014 at 05:52 PM 0
Share

What did you refer with "click anywhere"? The method Input.Get$$anonymous$$ouseButton(0) receives clicks from everywhere on the game window.

avatar image meat5000 ♦ · Dec 15, 2014 at 05:56 PM 0
Share

Or 'nowhere' on the game window.

avatar image $$anonymous$$ · Dec 15, 2014 at 06:00 PM 0
Share

What i mean is how would i get clicks from just the button?

Show more comments

1 Reply

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

Answer by taxvi · Dec 15, 2014 at 06:04 PM

 function OnGUI(){
     if(GUI.Button(new Rect(50, 50, 200, 40), "load new level"){
     Application.LoadLevel("TEST");
     }
 }
Comment
Add comment · Show 4 · 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 Fran-Martin · Dec 15, 2014 at 06:08 PM 0
Share

You were confused by the method's name. Get$$anonymous$$ouseButton doesn't mean that there is a button in the scene, it refers to the mouse's button.

avatar image taxvi · Dec 15, 2014 at 06:11 PM 1
Share

this code creates a button on the screen, and I think this is exactly what he wants

avatar image $$anonymous$$ · Dec 15, 2014 at 06:24 PM 0
Share

There is a syntax error in your code because when I try to run it, it comes up with errors Assets/Onclick.js(3,56): BCE0044: expecting ), found '{'. Assets/Onclick.js(6,1): BCE0044: expecting EOF, found '}'.

avatar image MrSoad · Dec 15, 2014 at 06:35 PM 0
Share

It is missing a ) bracket, change this line to this :

 if (GUI.Button(new Rect(50, 50, 200, 40), "load new level")) {

and hopefully the error will be gone.

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

Loading Game Object from one scene to AR scene 0 Answers

Changing start scene gui size main menu 0 Answers

Scene Load Issues 1 Answer

Unity Freezes and Deletes Everything in My Scene 0 Answers

HELP Game Scene 8 (-1) Cannot be loaded because it has not been added to the build settings 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