First of all, I’m new here. I had to change my password because I somehow screwed up my username where it displayed my then-password. I meant for it to be “LordFredrik” XD I changed the password lol.
Okay, to the point.
I just came to Unity 4 or so, I think, from RPG Maker VX Ace scripting in order to escape its confines and make the transition to 3D models and other things. I was surprised that I was able to use normal / bump maps. XD
However, I’m getting off track. My hiccup pertains to audio.
Now, my intention is to write a C# script for looping OGG Vorbis background music for use in my game(s), since it doesn’t seem to support the LOOPSTART and LOOPLENGTH flags that RPG Maker supported and I relied on for Nintendo-like looping music. I’m confused: I must be missing something, or it needs to be scripted. Basically, I want to learn how to properly loop music, or to be pointed in the right direction for me to script it myself.
What I do is basically have a loopable audio clip, and then I just play that audio clip on an AudioSource component on a GameObject. The AudioSource.loop is set to “true”. You don’t need scripting for that. There is even a checkbox in the inspector.
Not sure what you mean? Do you mean from the same audio file? I’d suggest you chop it up into pieces if you want to have a part that is loopable and a part that is not loopable. You can use Audacity, Cubase, etc for that.
Then you’ll have to make a script that plays from a certain point in an audio file, which is really hard to pull off if you want to sync the loops yourself in C# code. I’d still suggest you cut it into pieces, and then loop the loopable part when the first audio clip finished playing.
Oh, well. I had hoped not to have to cut my files apart, but since they’re OGG I can TRY to script something to look for LOOPLENGTH/START and sync them using variables. I’ll read up on that.
Yea the problem is that it’s really hard to generalize. You’ll have to grab those tags you added, and then find the exact sample where you want to loop from to have a seemless loop.
I can answer this one. Nope, I don’t think there’s support for this. The best way to accomplish this right now is to rely on PlayScheduled. It will let you with sample accuracy trigger the looping part exactly where the intro part ends, but you’ll need the intro and loopable part to be two separate audio clips.