Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by travelplays the world · Sep 17, 2015 at 03:06 AM · javascriptsceneunity5switchlevelload

how to make a script that goes to the next scene if you click a gameobject in unity 5

in the old unity i learned from a tutorial how to make a script to do that but now in unit 5 it doesn't work. can someone help me with changing the code so that it works. on this link is the tutorial youtube link

and this is the code line in java

hope someone can help me

greetings danny

 var levelToLoad : int;
 var soundhover : AudioClip;
 var beep : AudioClip;
 var QuitButton=false;
 function OnMouseEnter(){
 GetComponent.<AudioSource>().PlayOneShot(soundhover);
 }
 function OnMouseUp(){
 GetComponent.<AudioSource>().PlayOneShot(beep);
 yield new WaitForSeconds(0.35);
 if(QuitButton){
 Application.Quit();
 }
 else{
 Application.LoadLevel(levelToLoad);
 }
 }
 @script RequireComponent(AudioSource)


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 Hellium · Sep 16, 2015 at 01:16 PM 0
Share

Are you sure there is a collider on the object ? It's necessary if you want On$$anonymous$$ouseUp to be called.

avatar image travelplays the world Hellium · Sep 16, 2015 at 06:12 PM 0
Share

yes it has a collider that's why i think it weird that it doesn't work but only on unit 5

avatar image Hellium travelplays the world · Sep 16, 2015 at 06:31 PM 0
Share

Have you an Event System in your scene ?

Show more comments
avatar image travelplays the world · Sep 17, 2015 at 04:52 AM 0
Share

i did and the only thing that change is the shadow on the object that's clickt . maybe you can try to make a scene yourself if you have time ?

2 Replies

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

Answer by Hellium · Sep 17, 2015 at 06:42 AM

I made an empty scene to test, here are the indications :

  • Make sure the scene is in the Build Settings

  • Make sure there is a collider to the object. The object musn't Ignore Raycast layer

  • Add the script you've created, but don't forget that Application.Quit can be called in a build only. Take a look here for the workaround in the editor.

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
avatar image
0

Answer by Darkathion · Sep 17, 2015 at 07:29 AM

using UnityEngine; using System.Collections;

public class LoadOnClick : MonoBehaviour {

 public GameObject loadingImage;
 
 public void LoadScene(int level)
 {
     loadingImage.SetActive(true);
     Application.LoadLevel(level);
 }

}

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Hi! I am trying to use SceneManagement, but I keep getting errors. 1 Answer

Loading and Unloading scenes 2 Answers

multi scene editor 0 Answers

*JavaScript* High Score help (Need help with player prefs) 1 Answer

Please explain a switch statement? 4 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