Okey, iam the last one who knows how to write a code
but is this so difficult, that nobody has done it till now? There are allready a lot of scripts. I think all u need is to have the 4 Importent items: PlayEvent, Ambient, Switch and State.
Here a code i find in the Net. Maybe we can together find a solution or a overall special event:
{
uint bankID;
// Use this for initialization
protected void LoadBank () {
AkSoundEngine.LoadBank ("HEREBANKNAME", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
}
// Update is called once per frame
void Update () {
}
public void PlayEvent (string eventName)
{
AkSoundEngine.PostEvent (eventName, gameObject);
}
public void StopEvent (string eventName, int fadeout)
{
uint eventID;
eventID = AkSoundEngine.GetIDFromString (eventName);
AkSoundEngine.ExecuteActionOnEvent (eventID, AkActionOnEventType.AkActionOnEventType_Stop, gameObject, fadeout * 1000, AkCurveInterpolation.AkCurveInterpolation_Sine);
}
public void PauseEvent (string eventName, int fadeout)
{
uint eventID;
eventID = AkSoundEngine.GetIDFromString (eventName);
AkSoundEngine.ExecuteActionOnEvent (eventID, AkActionOnEventType.AkActionOnEventType_Pause, gameObject, fadeout * 1000, AkCurveInterpolation.AkCurveInterpolation_Sine);
}
public void ResumeEvent (string eventName, int fadeout)
{
uint eventID;
eventID = AkSoundEngine.GetIDFromString (eventName);
AkSoundEngine.ExecuteActionOnEvent (eventID, AkActionOnEventType.AkActionOnEventType_Resume, gameObject, fadeout * 1000, AkCurveInterpolation.AkCurveInterpolation_Sine);
}
}
the Playmaker code for Audio is
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Audio)]
[Tooltip("Plays the Audio Clip set with Set Audio Clip or in the Audio Source inspector on a Game Object. Optionally plays a one shot Audio Clip.")]
public class AudioPlay : FsmStateAction
{
[RequiredField]
[CheckForComponent(typeof(AudioSource))]
[Tooltip("The GameObject with an AudioSource component.")]
public FsmOwnerDefault gameObject;
[HasFloatSlider(0,1)]
[Tooltip("Set the volume.")]
public FsmFloat volume;
[ObjectType(typeof(AudioClip))]
[Tooltip("Optionally play a 'one shot' AudioClip. NOTE: Volume cannot be adjusted while playing a 'one shot' AudioClip.")]
public FsmObject oneShotClip;
[Tooltip("Event to send when the AudioClip finishes playing.")]
public FsmEvent finishedEvent;
private AudioSource audio;
public override void Reset()
{
gameObject = null;
volume = 1f;
oneShotClip = null;
finishedEvent = null;
}
public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);
if (go != null)
{
// cache the AudioSource component
audio = go.audio;
if (audio != null)
{
var audioClip = oneShotClip.Value as AudioClip;
if (audioClip == null)
{
audio.Play();
if (!volume.IsNone)
{
audio.volume = volume.Value;
}
return;
}
if (!volume.IsNone)
{
audio.PlayOneShot(audioClip, volume.Value);
}
else
{
audio.PlayOneShot(audioClip);
}
return;
}
}
// Finish if failed to play sound
Finish();
}
public override void OnUpdate ()
{
if (audio == null)
{
Finish();
}
else
{
if (!audio.isPlaying)
{
Fsm.Event(finishedEvent);
Finish();
}
else if (!volume.IsNone && volume.Value != audio.volume)
{
audio.volume = volume.Value;
}
}
}
}
}
how to modify it, that u can use ur audio events, switches aso in playmaker?