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 /
avatar image
0
Question by VicciGames · Aug 13, 2019 at 01:19 AM · touchandroid buildscene-loadingscene load

Issue with scene changing in Android Build. Buttons register touches but the functions called dont work.

I am trying to figure this out. I built an .apk to load onto my device to test it out. I am not using unity remote, as it does not work for me. Nor' am I using any debug services like ADB as my usb port on my phone is not working.
I run the application fine on the phone. I have a Samsung S9+ with the highest API being 29 I believe currently. I wanted to assume that the OnClick() callback function doesn't work with Touch Phones, but I couldn't find a google search that supported that argument.
I have a start button that changes the scene to the main level selector. I use Application.LoadScene(int sceneIndex) to change scenes. This is where I assumed the OnClick() callback doesn't work because the animation for the button script works perfectly; it does its thing.
Is there something I am missing?
Here is the code. Everything runs completely fine on unity editor and PC.

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 using System;
 using SimpleJSON;
 
 public class HomeController : BaseController
 {
     private const int PLAY = 0, RATE = 2;
     public ToggleButton tgSound, tgMusic;
     protected override void Start()
     {
         base.Start();
         GameState.currentMode = GameState.GameMode.Challenge;
         tgSound.IsOn = Sound.instance.IsEnabled();
         tgMusic.IsOn = Music.instance.IsEnabled();
         Music.instance.Play(Music.Type.MainMusic, true);
     }
 
     public void OnToggleSound()
     {
         tgSound.Toggle();
         Sound.instance.SetEnabled(tgSound.IsOn);
         Sound.instance.PlayButton();
     }
 
     public void OnToggleMusic()
     {
         tgMusic.Toggle();
         Music.instance.SetEnabled(tgMusic.IsOn, true);
         Sound.instance.PlayButton();
     }
 
     public void OnClick(int index)
     {
          Debug.Log("Button Pressed");
         Sound.instance.PlayButton();
         Debug.Log("Sound Played");
         switch (index)
         {
             case PLAY:
                 
                 CUtils.LoadLevel(1);
                 Debug.Log("Level Loaded");
                 
                 GameState.currentMode = GameState.GameMode.Challenge;
                 break;
             case RATE:
                 CUtils.RateGame();
                 break;
         }
     }
 }


This code handles the actual scene change.


               

     public static void LoadLevel(int levelIndex)
     {
         SceneManager.LoadScene(levelIndex);
         SetPreviousScene();
     }

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

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

Answer by VicciGames · Aug 17, 2019 at 12:11 AM

Issue was singletons were not being correctly setup at start. this halted any code of course after the error. Used ADB logcat on an android device i forgot i had. Luckily.

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 RetroGeek46 · Aug 13, 2019 at 07:37 AM

Does the button work in Editor?

If it doesn't, maybe you haven't referenced your OnClick() method script to the button from Inspector (drag and drop). You need to either have a reference to the button from your script and then add a listener or such, or simply drag the object containing this script on to the button and select the OnClick() method that you have written.

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 VicciGames · Aug 13, 2019 at 11:14 AM 0
Share

It works in editor and PC build. The onclick callback events are not working on an android build

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

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

Related Questions

How to transition from Load to scene ? 1 Answer

Unity on android doesn't load async scenes 1 Answer

Is there any ideas to load Unity scene asynchronously? 1 Answer

Load Scene from .unity File 1 Answer

Scene freezes after loaded 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