Skip to content

Instantly share code, notes, and snippets.

@athiedmann
athiedmann / FMODAudioManager.cs
Created October 4, 2023 20:47
Unity FMOD Audio Manager with Scene-Based Control and Event Management. Events are stored and called via scriptable objects.
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
using FMOD.Studio;
using UnityEngine.SceneManagement;
public class FMODAudioManager : MonoBehaviour
{
public bool useDebug;
public static FMODAudioManager instance { get; private set; }
@athiedmann
athiedmann / EventPositionConfiner.cs
Created October 3, 2023 22:20
A variation of the Wwise 301 Volumetric Script for the Wwise Adventure Game, modified and adapted for the Unity 3DGK. For details on how to use, see https://www.youtube.com/watch?v=QzRtPzJxco8&ab_channel=Audiokinetic
using UnityEngine;
using System.Collections;
////////////////////////////////////////////////////////////////////////
//
// Adapted and modified version of Volumetric Script from Wwise 301
//
////////////////////////////////////////////////////////////////////////
[RequireComponent(typeof(Collider))]
@athiedmann
athiedmann / WwiseObjectOcclusion.cs
Created October 3, 2023 22:15
Audio object occlusion in Unity with WwiseObjectOcclusion. Fires a raycast when player enters a sphere collider range and detects if objects are between player and item. If so, occlusion is applied.
using UnityEngine;
////////////////////////////////////////////////////////////////////////
//
// Adapted and modified from the Occlusion Script from Cujo Sound video "Wwise and Unity - Basic Raycasting To Create Occlusion Parameters"
//
////////////////////////////////////////////////////////////////////////
//Uses Logger.cs, there's a commented version using the Unity Debugger wrapped in a region below
@athiedmann
athiedmann / WwiseAmbientOcclusion.cs
Last active October 3, 2023 22:15
Optimize audio occlusion with the WwiseAmbientOcclusion script for Unity. This script checks if player has entered specific zones and applies occlusion appropriately to dynamic change audio playback.
using UnityEngine;
//Uses Logger.cs, there's a commented version using the Unity Debugger wrapped in a region below
public class WwiseAmbientOcclusion : MonoBehaviour
{
#if UNITY_EDITOR
public bool DebugScript = false;
#endif
public GameObject AudioListener;
@athiedmann
athiedmann / Logger.cs
Created October 3, 2023 22:03
This is liortal's script, which serves as a customizable logging utility for Unity projects. It wraps Unity's internal logger functions (e.g., Debug.Log, Debug.LogWarning, Debug.LogError) and allows you to enable or disable logging at compile time based on a defined symbol. Original post -> https://tinyurl.com/4un88vyn
using UnityEngine;
////////////////////////////////////////////////////////////////////////
//
// From liortal's script that was posted in the Unity forum
//
////////////////////////////////////////////////////////////////////////
/// <summary>
/// A logger that wraps Unity's internal logger.
@athiedmann
athiedmann / EllenWwiseManager.cs
Last active October 6, 2023 18:23
The "EllenWwiseFootstepManager" script in Unity handles Ellen's footsteps and landing sounds based on detected ground materials using Wwise Switches. Add "Material: Stone" to appropriate layers in-game.
using UnityEngine;
public class EllenWwiseManager : MonoBehaviour
{
// Enum to represent different material type
#if UNITY_EDITOR
private enum CURRENT_MATERIAL { STONE, PUDDLE, GRASS, EARTH, VEGETATION };
#endif
[Header("Wwise Events")]
@athiedmann
athiedmann / ThirdPersonPlayerFootstepManager.cs
Last active October 4, 2023 18:10
Footstep Manager script for Unity + Wwise
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonPlayerFootstepManager : MonoBehaviour
{
// Enum to represent different material type
private enum CURRENT_MATERIAL { STONE, PUDDLE, GRASS, EARTH, VEGETATION };
[SerializeField] bool materialCheckConfigured = false;
@athiedmann
athiedmann / AudioManager.cs
Last active July 10, 2023 17:01
The AudioManager, AudioPlayer, and SoundData scripts manage audio in small Unity games. AudioManager handles clips and events, manages sources efficiently. AudioPlayer plays clips based on events, while SoundData organizes clips. Attach AudioManager to an object, create SoundData to store clips, assign it. Modify code as needed.
using UnityEngine.Audio;
using UnityEngine;
using System.Collections.Generic;
public class AudioManager : MonoBehaviour
{
[SerializeField]
private bool useDebug;
public List<SoundData> soundDataList;
@athiedmann
athiedmann / WwisePlayerLoopEvents.cs
Last active October 3, 2023 22:09
A custom script for handling Wwise looping events within Unity. It acts like a component, assign the necessary events and select playback behaviour. Modify the script as needed for your project.
using UnityEngine;
public class WwisePlayerLoopEvents : MonoBehaviour
{
#if UNITY_EDITOR
[SerializeField] bool DebugScript;
#endif
[Header("Playback Settings")]
[SerializeField] bool playOnStart;