Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 Stefano9528 · Jul 19, 2015 at 06:53 PM · androidbuttonscene

Changing scene with button android

Hi everyone. I thought that changing my scenes was an easy part of my project but it doesn't work.I'm creating an android project. I have a menù and some buttons in it. I made the script with the function for changing scene. The button is interactable. I put this function in the OnClick () of the button. But either with the mouse and with the unity remote the button doesn't work at all. What am I missing? Thanks

using UnityEngine; using System.Collections;

public class MenùSelector : MonoBehaviour {

public void SceneSelector (int ScenesIndex) { Application.LoadLevel (ScenesIndex); }

}

Comment
Add comment · Show 3
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 Stefano9528 · Jul 20, 2015 at 08:15 AM 0
Share

Someone? I have to add touch input in my script?

avatar image Stefano9528 · Jul 20, 2015 at 11:33 AM 0
Share

It could be a problem with the UI ? All of my buttons don't change color when highlighted or pressed...

avatar image saschandroid · Jul 20, 2015 at 11:43 AM 0
Share

I don't know if it has anything to do with your question but there is a grave accent in $$anonymous$$en*ù*Selector.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KdRWaylander · Jul 20, 2015 at 08:20 AM

Hi, i don't think you can have a parameter in the function you call: int ScenesIndex is never set.

 public void SceneSelector () {
    int ScenesIndex;
 
    //You need to find a condition like with checkboxes
    //or based on the name of the button that calls this function
 
    /*
    if () {
       ScenesIndex = 1;
    } else if () {
       ScenesIndex = 2;
    }
    */
 
    Application.LoadLevel(ScenesIndex);
 }



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 Stefano9528 · Jul 20, 2015 at 02:36 PM 0
Share

I thought that this parameter would be passed from the inspector in the OnClick () function. Example: When I press the button It changes Scenes from Scene 0 to scene 1 . The index 1 or 0 can be choosen in the build settings.

avatar image KdRWaylander · Jul 21, 2015 at 01:43 PM 0
Share

If you just wanna switch to next scene with one button you can use that:

 public void LoadNextScene()
     {
         var nextLevel = (Application.loadedLevel + 1) % Application.levelCount;
         Application.LoadLevel(nextLevel);
     }

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Android: Scene change (Application.LoadLevel) has no effect 3 Answers

How to make a No Ads Button 0 Answers

Android Button With Raycast 3 Answers

Onscreen fire button for FPS games. 1 Answer

Android Error 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