Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Audio / SFX / Player / Footstep / PlaySoundAnimation.cs
@Rackday Rackday on 29 Oct 621 bytes Major Update
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;

public class PlaySoundAnimation : MonoBehaviour
{
    [SerializeField] private Sound[] sfx;

    public void PlaySound(string name)
    {
        Sound s = SearchSound(name);

        if (s != null)
        {
            AudioManager.Instance.Play(s.source, s.clip);
        }

        else
        {
            Debug.LogError($"Sound Not Found with the name: {name}");
        }
                
    }

    private Sound SearchSound(string name) => Array.Find(sfx, sound => sound.name == name);
}