In your onBuild, “success” will be true for successful builds and false for failed builds. Handle failure however you like.
For successful builds, you can get an array of all events in the project like this:
Each event has an array called “markerTracks”, each MarkerTrack has an array called “markers”, and each marker has some different data depending on what kind of marker it is. The easiest way to get a feel for the different data layouts is to explore the data model in the FMOD Studio Console window (Ctrl+0). Here are some useful commands for that:
// Get all events
var events = studio.project.model.Event.findInstances()
// See a list of events
// See a list of marker tracks within an event
// See a list of markers with a track
// Show the json data structure of a given marker
var file = studio.system.getFile(outputPath);
I’ll leave robust error checking, etc. as an exercise for the reader. For the outputPath, note that you can get the current path of the FMOD Studio project file with:
In my case, our FMOD studio project lives inside our Unity project folder, so I just took studio.project.filePath and walked up the directory tree until I found the Unity project root, than tacked on “/Assets/Resources/markers.json”. You can do whatever makes the most sense for your game.
On the game side, you’ll need some way to deserialize the .json file into some usable data structure. Unity has a nice JSONUtility class that makes this easy. Once you’ve deserialized the data, it should be trivial to figure out what markers you have available, what they’re called, where they fall in time, and any other data you chose to capture in your export script.
Feel free to correct inaccuracies or point out better ways of doing this!