Hey guys I started integrating Master Audio (Popular Asset Store Audio Management Plugin) in ORK for my project and I thought I'd share it in case anybody else needs it.
I just started on it, so far I have PlaySoundGroup options. All of them like PlayOneShot, Play at Vector3 position, Play at Transform + Follow Transform.

Some known issues:
ORK Inspector is also acting wonky when I select Play At Transform and Play At Vector3 toggles. I need to brush up on my editor Code.

I'll be add rest of the Master Audio Functions Next week. I'll post here with updates.

#1: PlaySound node - Plays MasterAudio SoundGroups
image

MasterAudioPlaySoundStep.CS
using UnityEngine;
using ORKFramework;
using ORKFramework.Menu;
using ORKFramework.Reflection;
using ORKFramework.Behaviours;
using System.Collections.Generic;
using DarkTonic.MasterAudio;
namespace ORKFramework.Events.Steps
{
[ORKEditorHelp("MasterAudio PlaySound", "PlaysMaster Audio Sounds", "")]
[ORKEventStep(typeof(BaseEvent))]
[ORKNodeInfo("MasterAudio")]
public class MasterAudioPlaySoundStep : BaseEventStep
{
[ORKEditorHelp("SoundGroup Name", "The name of the MasterAudio SoundGroup to Play.\n", "")]
[ORKEditorInfo(expandWidth = true, labelText = "SoundGroup Name")]
public StringValue SoundGroupName = new StringValue();

[ORKEditorHelp("Play Once and Forget", "Same as PlaySound, but does not return a PlaySoundResult object so it has 0 bytes of GC Allocation.\n", "")]
[ORKEditorInfo(labelText = "Play Once and Forget")]
public bool OnceAndForget;

[ORKEditorHelp("Play At Vector3Position", "Plays Sound at defined Vector3 position", "")]
[ORKEditorInfo(labelText = "Play At Vector3Position")]
public bool PlayAtVector3Position;
[ORKEditorLayout("PlayAtVector3Position", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Vector3 Position")]
public Vector3Value Vector3 = new Vector3Value();


[ORKEditorHelp("PlayAtTransformPosition", "Plays Sound at defined Transform position", "")]
[ORKEditorInfo(expandWidth = true, labelText = "Play at Transform Position")]
public bool PlayAtTransformPosition;
[ORKEditorLayout("PlayAtTransformPosition", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Transform")]
public EventObjectSetting Transform = new EventObjectSetting();
[ORKEditorLayout("PlayAtTransformPosition", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Follow Transform With Sound")]
public bool Follow = false;


[ORKEditorHelp("SetParameters", "", "")]
public bool SetParameters = false;
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Volume Percentage")]
public EventFloat VolumePercentage = new EventFloat();
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "Pitch")]
public EventFloat Pitch = new EventFloat();
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "DelaySoundTime")]
public EventFloat DelaySoundTime = new EventFloat();
[ORKEditorLayout("SetParameters", true, endCheckGroup = true, autoInit = true)]
[ORKEditorInfo(labelText = "VariationName")]
public StringValue VariationName = new StringValue();


private List<GameObject> TransformsList;


public MasterAudioPlaySoundStep()
{

}

public override void Execute(BaseEvent baseEvent)
{

this.TransformsList = this.Transform.GetObject(baseEvent);

if (PlayAtVector3Position)
{
if (OnceAndForget)
{
if (SetParameters)
MasterAudio.PlaySound3DAtVector3AndForget(SoundGroupName.GetValue(), Vector3.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtVector3AndForget(SoundGroupName.GetValue(), Vector3.GetValue());
}
else
{
if (SetParameters)
MasterAudio.PlaySound3DAtVector3(SoundGroupName.GetValue(), Vector3.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtVector3(SoundGroupName.GetValue(), Vector3.GetValue());
}
}

if (PlayAtTransformPosition)
{
for (int i = 0; i < TransformsList.Count; i++)
{
if (OnceAndForget)
{
if (SetParameters)
{
if (Follow)
MasterAudio.PlaySound3DFollowTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
}
else
{
if (Follow)
MasterAudio.PlaySound3DFollowTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform);
else
MasterAudio.PlaySound3DAtTransformAndForget(SoundGroupName.GetValue(), TransformsList[i].transform);
}
}
else
{
if (SetParameters)
{
if (Follow)
MasterAudio.PlaySound3DFollowTransform(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound3DAtTransform(SoundGroupName.GetValue(), TransformsList[i].transform, VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
}
else
{
if (Follow)
MasterAudio.PlaySound3DFollowTransform(SoundGroupName.GetValue(), TransformsList[i].transform);
else
MasterAudio.PlaySound3DAtTransform(SoundGroupName.GetValue(), TransformsList[i].transform);
}
}
}

}

if (!PlayAtVector3Position && !PlayAtTransformPosition)
{
if (OnceAndForget)
{
if (SetParameters)
MasterAudio.PlaySoundAndForget(SoundGroupName.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySoundAndForget(SoundGroupName.GetValue());
}
else
{
if (SetParameters)
MasterAudio.PlaySound(SoundGroupName.GetValue(), VolumePercentage.GetValue(baseEvent), Pitch.GetValue(baseEvent), DelaySoundTime.GetValue(baseEvent), VariationName.GetValue());
else
MasterAudio.PlaySound(SoundGroupName.GetValue());
}

}


baseEvent.StepFinished(this.next);
}



/*
============================================================================
Node name functions
============================================================================
*/
public override string GetNodeDetails()
{
return "";
}
}
}
Post edited by hellwalker on
  • Good job :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.