Hey Everyone! I was reading through this post here and it seems like @jashan accomplished what I am trying to do.
Oculus Spatializer is not usable with PSVR and I have been switching to Resonance Audio for compatibility on multiple platforms. I want to make a script that can change platform exclusion on the Oculus Spatializer plugin that is on a ton of events.
I am not using preset effects and can’t batch edit the events due to their differences. Is there a way to access and set the platform exclusion proprety of Oculus Spatializer? Accessing that is where I got stuck. Any help is very appreciated!
I found a lead on this, but am not as sure about the specific modification of platform exclusion in a way that is safe.
Using something like this, I can see what platform are excluded. It looks like this is not a pluginParameter though and changing it would mean changing several values? Ideally, I want to safely switch what platforms are excluded and not.
To add a platform to an effect’s excludedPlatforms array, you need to add it via the effect’s relationships - for example:
// get current platform
var platform = studio.project.workspace.projectSettings.activePlatform;
// add it to the effect's excluded platforms
eventEffect.relationships.excludedPlatforms.add(platform);
I’ve modified your script to use the effect’s relationships to toggle whether the Oculus Spatializer effect is excluded from the currently selected plaform. Give it a try and let me know whether you run into any issues.
studio.menu.addMenuItem({
name: "Toggle Oculus Spatializers for Current Platform",
execute: function() {
var platform = studio.project.workspace.projectSettings.activePlatform; // get current platform
var selectedEvents = studio.window.browserSelection();
// iterate over browser selection
selectedEvents.forEach(function(event)
{
// check whether event is selected
if (event.isOfExactType("Event"))
{
var effectChain = event.masterTrack.mixerGroup.effectChain;
var effectChainEffects = effectChain.effects;
// iterate over effects in event's master track
effectChainEffects.forEach(function(eventEffect)
{
// if current effect is a plugin effect
if (eventEffect.isOfExactType("PluginEffect"))
{
// if plugin effect is oculus spatializer
if (eventEffect.plugin.identifier === "Oculus Spatializer")
{
// check whether effect is already excluded so exclusion can be toggled
var index = platformsArrayIncludes(eventEffect.excludedPlatforms, platform)
if (index >= 0)
{
eventEffect.relationships.excludedPlatforms.remove(platform);
}
else
{
eventEffect.relationships.excludedPlatforms.add(platform);
}
}
}
});
}
});
},
});
// helper function to check whether platform is already excluded
function platformsArrayIncludes(array, platformToCheck){
var index = -1;
array.forEach(function(platform){
index++;
if (platform.id === platformToCheck.id) return index;
});
return index;
}
I was finally able to test this out, and it works perfectly! Really amazed at how much scripting can do. Thank you very much!
For anyone wondering, I am using this to disable Oculus Spatializer on PSVR builds. When using PSVR, I run another version of the script to disable Resonance Audio on Oculus builds. For my purposes, this lets me test or change spatialization solutions on the fly.