using System.Collections; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; namespace KairoEngine.SFX { [System.Serializable] [HideMonoScript] [CreateAssetMenu(menuName = "KairoEngine/SFX/Group", fileName = "SFXGroup", order = 2)] public class SFXGroup : SerializedScriptableObject { [Space] public Dictionary clips = new Dictionary(); public void Play(PhysicMaterial physicMaterial, Vector3 position) { if(!physicMaterial) { Debug.LogError($"Missing physicMaterial in call to SFXGroup ({this.name})", this); return; } string materialName = physicMaterial.name.Replace(" (Instance)", ""); SFXClip clip = null; foreach(KeyValuePair item in clips) { if(item.Key.name == materialName) clip = item.Value; } if(clip != null) SoundController.EmmitSound(clip, position); else Debug.LogError($"Missing SFX clip for material \'{materialName}\' in SFXGroup ({this.name})", this); } } }