Audio Source Changes

This commit is contained in:
pelpanagiotis
2026-01-10 23:46:09 +02:00
parent 7ab01263a1
commit 9df38fd3b2
34 changed files with 78010 additions and 242491 deletions

View File

@@ -0,0 +1,28 @@
using UnityEngine;
public class MyAudioPlayer : MonoBehaviour
{
private AudioSource audioSource;
void Awake()
{
// Try to get it from the current object first
audioSource = GetComponent<AudioSource>();
// Fallback: search the scene (safer than lazy Find at Play)
if (audioSource == null)
{
GameObject go = GameObject.Find("AudioSource");
if (go != null)
{
audioSource = go.GetComponent<AudioSource>();
}
}
// Final safety check
if (audioSource == null)
{
Debug.LogError("AudioSource not found!");
}
}
}