Detect if event has no instruments

I am porting Empire of Ember to use FMOD. Empire of Ember already has all sounds assigned using Unity’s AudioSource, however I want to be able to port certain audio situations to use FMOD instead. If for an event there is no assigned instrument, I need to be able to tell that in code to continue to use Unity’s AudioSource.

How do I tell if an event has no assigned instruments?

You are only able to detect this within the FMOD Studio application. You can have something like the following code in the Window > Console dialog to search each event’s timeline & parameter sheet for instruments.

var allEvents = studio.project.model.Event.findInstances();
allEvents.forEach(function(event) {
  var allSheets = event.parameters;
  allSheets.push(event.timeline);
  var allModules = [];

  allSheets.forEach(function(sheet) {
  	allModules.push(sheet.modules);
	});
	var merged = [].concat.apply([], allModules); // The Javascript version provided in FMOD Studio does not allow for array.flat()
	if(merged.length <= 0) {
		console.log("Event '" + event.name + "' does not contain any instruments");
	}
})

You can then use this information to tell Unity which events to use the original AudioSource.