Initial commit: Star of Words Unity project
Snapshot of the existing Unity 6 language-learning word game before any refactoring. Adds Unity .gitignore and .gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
commit
ecb1c9edea
1455 changed files with 933295 additions and 0 deletions
41
Assets/Scripts/3.5/MusicManager.cs
Normal file
41
Assets/Scripts/3.5/MusicManager.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class MusicManager : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ MÜZIKLER (25 MP3) ━━━━━━━━━━━━━━━━━")]
|
||||
public AudioClip[] songs;
|
||||
|
||||
[Header("━━━ AUDIO SOURCE ━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public AudioSource audioSource;
|
||||
|
||||
private int lastIndex = -1;
|
||||
|
||||
// ============================================================
|
||||
void Start()
|
||||
{
|
||||
PlayRandom();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (!audioSource.isPlaying)
|
||||
PlayRandom();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void PlayRandom()
|
||||
{
|
||||
if (songs == null || songs.Length == 0) return;
|
||||
|
||||
int index;
|
||||
do
|
||||
{
|
||||
index = Random.Range(0, songs.Length);
|
||||
}
|
||||
while (index == lastIndex && songs.Length > 1); // aynı şarkı üst üste gelmesin
|
||||
|
||||
lastIndex = index;
|
||||
audioSource.clip = songs[index];
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue