PJ/Assets/scripts/dotfs_scripts/ShopAudioDatabase.cs

34 lines
No EOL
914 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}