Skip to main content
added 161 characters in body
Source Link
CheckerT
  • 176
  • 10

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

Update:

LevelManager.cs

using UnityEngine; using System; public class LevelManager : MonoBehaviour { public Level[] levels; void Awake() { foreach (Level s in levels) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; s.length = s.clip.length; } } public void Play(string name) { Level s = Array.Find(levels, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + " not found!"); return; } s.source.Play(); } } 

Level Class

using UnityEngine; [System.Serializable] public class Level { [Header("General")] public string name; [HideInInspector] public float length; [Header("Audio")] public AudioClip clip; [HideInInspector] public AudioSource source; } 

This is the Level class in inspector

i think the import settings for one of the sounds

This is the import setting for one of the sounds.

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

Update:

LevelManager.cs

using UnityEngine; using System; public class LevelManager : MonoBehaviour { public Level[] levels; void Awake() { foreach (Level s in levels) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; s.length = s.clip.length; } } public void Play(string name) { Level s = Array.Find(levels, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + " not found!"); return; } s.source.Play(); } } 

Level Class

using UnityEngine; [System.Serializable] public class Level { [Header("General")] public string name; [HideInInspector] public float length; [Header("Audio")] public AudioClip clip; [HideInInspector] public AudioSource source; } 

This is the Level class in inspector

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

Update:

LevelManager.cs

using UnityEngine; using System; public class LevelManager : MonoBehaviour { public Level[] levels; void Awake() { foreach (Level s in levels) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; s.length = s.clip.length; } } public void Play(string name) { Level s = Array.Find(levels, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + " not found!"); return; } s.source.Play(); } } 

Level Class

using UnityEngine; [System.Serializable] public class Level { [Header("General")] public string name; [HideInInspector] public float length; [Header("Audio")] public AudioClip clip; [HideInInspector] public AudioSource source; } 

This is the Level class in inspector

i think the import settings for one of the sounds

This is the import setting for one of the sounds.

Split into paragraphs, minor edits, tagged as android
Source Link
CheckerT
  • 176
  • 10

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

Update:

LevelManager.cs

using UnityEngine; using System; public class LevelManager : MonoBehaviour { public Level[] levels; void Awake() { foreach (Level s in levels) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; s.length = s.clip.length; } } public void Play(string name) { Level s = Array.Find(levels, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + " not found!"); return; } s.source.Play(); } } 

Level Class

using UnityEngine; [System.Serializable] public class Level { [Header("General")] public string name; [HideInInspector] public float length; [Header("Audio")] public AudioClip clip; [HideInInspector] public AudioSource source; } 

This is the Level class in inspector

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

Update:

LevelManager.cs

using UnityEngine; using System; public class LevelManager : MonoBehaviour { public Level[] levels; void Awake() { foreach (Level s in levels) { s.source = gameObject.AddComponent<AudioSource>(); s.source.clip = s.clip; s.length = s.clip.length; } } public void Play(string name) { Level s = Array.Find(levels, sound => sound.name == name); if (s == null) { Debug.LogWarning("Sound: " + name + " not found!"); return; } s.source.Play(); } } 

Level Class

using UnityEngine; [System.Serializable] public class Level { [Header("General")] public string name; [HideInInspector] public float length; [Header("Audio")] public AudioClip clip; [HideInInspector] public AudioSource source; } 

This is the Level class in inspector

Split into paragraphs, minor edits, tagged as android
Source Link

Unity Audio plays with massive Delay5-10 second delay

I have wanted to make something like a rhythm game for Android in Unity, and withfor that iI needed to makewrite an audio manager to play my Songssongs and also sound effects in game-game. I have followed Brackeys tutorialBrackeys' tutorial for that (https://m.youtube.com/watch?v=6OT43pvUyfY&pp=ygUOQnJhY2tleXMgYXVkaW8%3D), and it worked fine for me, even with sounds up to 5 minutes long. Now i

Now I have built the game for android andAndroid, but if iI press a button to play this song, it does not work at all anymoreany more. Sometimes Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds and then, and then the sound plays. Also

Also, in a windowsWindows build this does not happen, and in editor-editor it isworks perfectly fine as well. I

I have tried setting the audio to best latencyBest Latency, iI have reimprotedreimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also i'mI'm not so good in englishEnglish so sorry for that :) )

Unity Audio plays with massive Delay

I have wanted to make something like a rhythm game for Android in Unity, and with that i needed to make an audio manager to play my Songs and also sound effects in game. I have followed Brackeys tutorial for that (https://m.youtube.com/watch?v=6OT43pvUyfY&pp=ygUOQnJhY2tleXMgYXVkaW8%3D) and it worked fine for me, even with sounds up to 5 minutes long. Now i have built the game for android and if i press a button to play this song it does not work at all anymore. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds and then the sound plays. Also, in a windows build this does not happen and in editor it is perfectly fine as well. I have tried setting the audio to best latency, i have reimproted all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also i'm not so good in english so sorry for that :) )

Unity Audio plays with 5-10 second delay

I have wanted to make something like a rhythm game for Android in Unity, and for that I needed to write an audio manager to play my songs and sound effects in-game. I have followed Brackeys' tutorial for that, and it worked fine for me, even with sounds up to 5 minutes long.

Now I have built the game for Android, but if I press a button to play this song, it does not work at all any more. Sometimes the build just crashes, sometimes nothing happens, and most of the time the whole app freezes for about 5 to 10 seconds, and then the sound plays.

Also, in a Windows build this does not happen, and in-editor it works perfectly fine as well.

I have tried setting the audio to Best Latency, I have reimported all assets multiple times, and nothing worked.

Any help is highly appreciated because this is my first project! ( Also I'm not so good in English so sorry for that :) )

Source Link
CheckerT
  • 176
  • 10
Loading