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
86
Assets/Scripts/2.0/LanguageSettingsController.cs
Normal file
86
Assets/Scripts/2.0/LanguageSettingsController.cs
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class LanguageSettingsController : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ DROPDOWNLAR ━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public TMP_Dropdown questionDropdown;
|
||||
public TMP_Dropdown answerDropdown;
|
||||
|
||||
[Header("━━━ BUTONLAR ━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public Button saveAndBackButton;
|
||||
|
||||
[Header("━━━ AUDIO ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public AudioClip clickSound;
|
||||
public AudioSource sfxSource;
|
||||
|
||||
void Start()
|
||||
{
|
||||
PopulateDropdowns();
|
||||
|
||||
questionDropdown.value = PlayerPrefs.GetInt("QuestionLangID", 1);
|
||||
answerDropdown.value = PlayerPrefs.GetInt("AnswerLangID", 0);
|
||||
|
||||
questionDropdown.RefreshShownValue();
|
||||
answerDropdown.RefreshShownValue();
|
||||
|
||||
saveAndBackButton.onClick.AddListener(() => { PlayClick(); SaveAndBack(); });
|
||||
}
|
||||
|
||||
void PopulateDropdowns()
|
||||
{
|
||||
List<string> languageNames = new List<string>
|
||||
{
|
||||
"Türkçe", // 0
|
||||
"English", // 1
|
||||
"Español", // 2
|
||||
"Deutsch", // 3
|
||||
"Français", // 4
|
||||
"Português" // 5
|
||||
};
|
||||
|
||||
questionDropdown.ClearOptions();
|
||||
answerDropdown.ClearOptions();
|
||||
|
||||
questionDropdown.AddOptions(languageNames);
|
||||
answerDropdown.AddOptions(languageNames);
|
||||
}
|
||||
|
||||
void SaveAndBack()
|
||||
{
|
||||
int qID = questionDropdown.value;
|
||||
int aID = answerDropdown.value;
|
||||
|
||||
PlayerPrefs.SetInt("QuestionLangID", qID);
|
||||
PlayerPrefs.SetInt("AnswerLangID", aID);
|
||||
PlayerPrefs.SetString("QuestionLangCode", ToCode(qID));
|
||||
PlayerPrefs.SetString("AnswerLangCode", ToCode(aID));
|
||||
PlayerPrefs.SetString("AppLanguage", ToCode(qID));
|
||||
PlayerPrefs.Save();
|
||||
|
||||
SceneManager.LoadScene("Anamen");
|
||||
}
|
||||
|
||||
void PlayClick()
|
||||
{
|
||||
if (sfxSource != null && clickSound != null)
|
||||
sfxSource.PlayOneShot(clickSound);
|
||||
}
|
||||
|
||||
string ToCode(int id)
|
||||
{
|
||||
return id switch
|
||||
{
|
||||
0 => "tr",
|
||||
1 => "en",
|
||||
2 => "es",
|
||||
3 => "de",
|
||||
4 => "fr",
|
||||
5 => "pt",
|
||||
_ => "en"
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue