34 lines
No EOL
914 B
C#
34 lines
No EOL
914 B
C#
using UnityEngine;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
|
||
[Serializable]
|
||
public class ShopAudioEntry
|
||
{
|
||
[Tooltip("ID звука из JSON (например: 'epic_buy_01')")]
|
||
public string id;
|
||
public AudioClip clip;
|
||
}
|
||
|
||
[CreateAssetMenu(fileName = "NewShopAudioDatabase", menuName = "Shop/Audio Database")]
|
||
public class ShopAudioDatabase : ScriptableObject
|
||
{
|
||
public List<ShopAudioEntry> audioEntries = new List<ShopAudioEntry>();
|
||
|
||
// Метод для поиска звука по ID
|
||
public AudioClip GetAudioClip(string id)
|
||
{
|
||
if (string.IsNullOrEmpty(id)) return null;
|
||
|
||
foreach (var entry in audioEntries)
|
||
{
|
||
if (entry.id == id)
|
||
{
|
||
return entry.clip;
|
||
}
|
||
}
|
||
|
||
Debug.LogWarning($"[ShopAudioDatabase] Звук с ID '{id}' не найден в базе!");
|
||
return null;
|
||
}
|
||
} |