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 /
avatar image
0
Question by RandomUser123 · Sep 22, 2014 at 09:11 PM · androideditoraudio

Audio behaves accordingly in editor but not android

I have a gameObject in my scene that has an Audio Source which plays the main themes music. When I choose to switch off the audio in the editor, it does so accordingly, then when I switch it back on, again, it behaves the way it's supposed to.

The problem is, if I was to repeat this process on my android build, the music will constantly play, I can't get it to stop. This couldn't be any more frustrating so if anyone has any solutions for me, i'd greatly appreciate it.

Edit

mainMenu.cs#

 void Start()
     {
         if (PlayerPrefs.GetInt("audio", optionsMenu.audio) == 1)
         {
             Camera.main.GetComponent<AudioListener>().enabled = true;
         }
 
         else if (PlayerPrefs.GetInt("audio", optionsMenu.audio) == 0)
         {
             Camera.main.GetComponent<AudioListener>().enabled = false;
         }
     }

optionsMenu.cs

void checkAudio() { if (noAudio.isOn == true) { audio = 0; PlayerPrefs.SetInt("audio", audio); yesAudio.isOn = false; }

         else if (yesAudio.isOn == true)
         {
             audio = 1;
             PlayerPrefs.SetInt("audio", audio);
             noAudio.isOn = false;
         }
 
         else if (yesAudio.isOn == false && noAudio.isOn == false)
         {
             audio = 1;
             PlayerPrefs.SetInt("audio", audio);
             yesAudio.isOn = true;
         }
     }


This is the code I'm using, the options menu function is run in the update, I keep the players input in a player pref for later use, so then when the main menu is loaded, I have it checking to see what that value is.

Like I said, this all runs when I play it in Unity, just not on android :/

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 roojerry · Sep 22, 2014 at 09:21 PM 0
Share

Where in your code are you calling AudioSource.Stop?

avatar image RandomUser123 · Sep 22, 2014 at 09:36 PM 0
Share

@brianruggieri I've updated my question, I disable the listener as I want all audio stopped

avatar image Nerevar · Sep 23, 2014 at 10:38 AM 0
Share

Hello,

When do you call checkAudio()?

Also your decision system seems very complicated for a very simple thing. Do you ever set noAudio.isOn to true?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Vunpac · Sep 25, 2014 at 06:59 AM

First - You can only have one AudioListener in a scene. That being said you are not required to get it like a component. You can just flat out use AudioListener.enabled.

Second - You can't use enabled with the AudioListener. You should be using AudioListener.pause.

Now depending on exactly what you want to do you may run into A LOT of buggy behavior. I have been messing about with it for quite some time, and came up with many workarounds. So just be aware you may run into a few more issues.

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

28 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

Related Questions

Audio popping on pause and volume change 1 Answer

AudioManager.Update & EditorOverhead taking CPU 1 Answer

Using Native Plugins in an Android Project and Executing in the Unity Editor 0 Answers

Problem with Editor folder 1 Answer

Play local Android/IOS audio files in unity game. 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