I’m creating a game in Unity (Targets: Mac/PC/Linux). I wish to play a 30 second looping track of music while the game loads.
I can code in C# and C++ outside of unity if that is needed. i use Visual studio 2017. The track is in MP3 format but I have the source so I can have it in other formats.
This is impossible to do within unity.
If you don’t want to code outside of unity, you could try setting up a small scene that starts right after unity’s splash screen finish playing and does your own splash screen from there along with your music. This is the simplest workaround I could think of.
create a empty gamaobject and insert this script into it.
create script in c# and write codes
using UnityEngine;
using System.Collections;
public class Carsound : MonoBehaviour {
public AudioClip awoogah;
public int carwait = 10;
bool keepPlaying=true;
void Start () {
StartCoroutine(SoundOut());
}
IEnumerator SoundOut()
{
while (keepPlaying){
audio.PlayOneShot(awoogah);
Debug.Log("ChOO-ChOO");
yield return new WaitForSeconds(carwait);
}
}
}