Adventure Creator Wikia
Advertisement

The following Actions are provided by laethyn on the AC forum.

Load/Unload a Soundbank:

Select the bank you want to deal with, then select whether you want to load or unload it

using UnityEngine;
using System.Collections.Generic;
using AK;
using AK.Wwise;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

	[System.Serializable]
	public class AK_LoadSoundbank : Action
	{

		public override ActionCategory Category { get { return ActionCategory.Sound; }}
		public override string Title { get { return "Load WWise Soundbank"; }}
		public override string Description { get { return "Load a WWise Soundbank"; } }

		public Bank mySoundBank;
		public enum loadUnload
		{
			Load,
			Unload
		};
		public loadUnload bankEvent;


		public override float Run ()
		{
			if (bankEvent == loadUnload.Load)
			{
				mySoundBank.Load();
			}
			else
			{
				mySoundBank.Unload();
			}

			return 0f;
		}

		#if UNITY_EDITOR

		public override void ShowGUI ()
		{
			if (this == null) return;

			var serializedObject = new SerializedObject(this);
			serializedObject.Update();
			SerializedProperty myBank = serializedObject.FindProperty("mySoundBank");
			EditorGUILayout.PropertyField(myBank, true);
			bankEvent = (loadUnload)EditorGUILayout.EnumPopup("Action:", bankEvent);

			serializedObject.ApplyModifiedProperties();

		}

		#endif
	}

}

Change Wwise Switch Select the new switch you want to switch to

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{
	[System.Serializable]
	public class AK_Switch : Action
	{

		public override ActionCategory Category { get { return ActionCategory.Sound; }}
		public override string Title { get { return "Set WWise Audio Switch"; }}
		public override string Description { get { return "Call Audio Switch Event."; } }

		public AK.Wwise.Switch switchToSet;

		public override float Run ()
		{ 
			switchToSet.SetValue(GameObject.Find("WwiseGlobal"));
			return 0f;
		}

		#if UNITY_EDITOR
		public override void ShowGUI ()
		{
			if (this == null) return;

			var serializedObject = new SerializedObject(this);
			serializedObject.Update();
			SerializedProperty switchEvent = serializedObject.FindProperty("switchToSet");
			EditorGUILayout.PropertyField(switchEvent, true);

			serializedObject.ApplyModifiedProperties();
		}
		#endif
	}

}

Call a Wwise Event Select the event you want to call. Select if it's a player as the object, or set the gameobject making the call. If left empty, it will just pass in the WwiseGlobal gameobject that should be auto generated in the scene

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

	[System.Serializable]
	public class AK_PlayAudioEvent : Action
	{

		public override ActionCategory Category { get { return ActionCategory.Sound; }}
		public override string Title { get { return "Play WWise Audio"; }}
		public override string Description { get { return "Play an audio event."; } }

		public AK.Wwise.Event eventToCall;
		public bool isPlayer;
		public GameObject sender;

		public override float Run ()
		{
			if (sender == null)
			{
				sender = GameObject.Find("WwiseGlobal");
			}
			if (isPlayer)
			{
				sender = KickStarter.player.gameObject;
			}

			eventToCall.Post(sender);
			return 0f;
		}

		#if UNITY_EDITOR

		public override void ShowGUI ()
		{
			if (this == null) return;

			var serializedObject = new SerializedObject(this);
			serializedObject.Update();
			SerializedProperty audioEvent = serializedObject.FindProperty("eventToCall");
			EditorGUILayout.PropertyField(audioEvent, true);

			isPlayer = EditorGUILayout.Toggle(new GUIContent("Player?"), isPlayer);

			if (!isPlayer)
			{
				sender = (GameObject)EditorGUILayout.ObjectField("Source:", sender, typeof(GameObject), true);
			}

			serializedObject.ApplyModifiedProperties();
		}
		#endif
	}

}


Set RTPC (int value change)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC {
    [System.Serializable]
    public class AK_SetRTPCIntParameter : Action {
        public override ActionCategory Category { get { return ActionCategory.Sound; } }
        public override string Title { get { return "Change RTPC value"; } }
        public override string Description { get { return "Change RTPC value."; } }

        [SerializeField] AK.Wwise.RTPC rtpcToSet;
        [SerializeField] float newValue;

        public override float Run() {
            rtpcToSet.SetValue(GameObject.Find("WwiseGlobal"), newValue);
            return 0f;
        }

#if UNITY_EDITOR
        public override void ShowGUI() {
            if (this == null) {
                return;
            }

            var serializedObject = new SerializedObject(this);
            serializedObject.Update();
            SerializedProperty rtpcEvent = serializedObject.FindProperty("rtpcToSet");
            EditorGUILayout.PropertyField(rtpcEvent, true);

            if (rtpcEvent != null) {
                newValue = EditorGUILayout.FloatField(newValue);

            }
            serializedObject.ApplyModifiedProperties();
        }
#endif
    }
}
Advertisement