功能批量实现 优化 服务端 新浮动小游戏框架 新界面UI
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
|
||||
public class UISoundRouter : MonoBehaviour
|
||||
{
|
||||
private const bool VerboseLogs = false;
|
||||
public static UISoundRouter Instance;
|
||||
|
||||
[SerializeField] private UISoundConfig soundConfig;
|
||||
@@ -51,16 +52,16 @@ public class UISoundRouter : MonoBehaviour
|
||||
|
||||
if (soundConfig == null)
|
||||
{
|
||||
Debug.LogWarning("[UISoundRouter] SoundConfig is null! Cannot build lookup.");
|
||||
if (VerboseLogs) Debug.LogWarning("[UISoundRouter] SoundConfig is null! Cannot build lookup.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log($"[UISoundRouter] Building lookup for {soundConfig.name} with {soundConfig.soundTable.Count} entries.");
|
||||
if (VerboseLogs) Debug.Log($"[UISoundRouter] Building lookup for {soundConfig.name} with {soundConfig.soundTable.Count} entries.");
|
||||
|
||||
foreach (var entry in soundConfig.soundTable)
|
||||
{
|
||||
lookup[entry.type] = entry;
|
||||
Debug.Log($"[UISoundRouter] Registered sound for {entry.type}: Hover={entry.hoverClip?.name}, Click={entry.clickClip?.name}");
|
||||
if (VerboseLogs) Debug.Log($"[UISoundRouter] Registered sound for {entry.type}: Hover={entry.hoverClip?.name}, Click={entry.clickClip?.name}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,12 +81,12 @@ public class UISoundRouter : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[UISoundRouter] Hover clip is null for type {type}");
|
||||
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] Hover clip is null for type {type}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
|
||||
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,22 +97,21 @@ public class UISoundRouter : MonoBehaviour
|
||||
|
||||
lastClickTime = Time.unscaledTime;
|
||||
|
||||
Debug.Log($"[UISoundRouter] PlayClick called for type: {type}");
|
||||
if (lookup != null && lookup.TryGetValue(type, out var entry))
|
||||
{
|
||||
if (entry.clickClip != null)
|
||||
{
|
||||
Debug.Log($"[UISoundRouter] Playing click clip: {entry.clickClip.name}");
|
||||
if (VerboseLogs) Debug.Log($"[UISoundRouter] Playing click clip: {entry.clickClip.name}");
|
||||
audioSource.PlayOneShot(entry.clickClip, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[UISoundRouter] Click clip is null for type {type}");
|
||||
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] Click clip is null for type {type}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
|
||||
if (VerboseLogs) Debug.LogWarning($"[UISoundRouter] No entry found for type {type} in lookup.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user