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
76
Assets/Scripts/3.5/ModSelectLanguageSettings.cs
Normal file
76
Assets/Scripts/3.5/ModSelectLanguageSettings.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ModSelectLanguageSettings : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ DROPDOWNLAR ━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public TMP_Dropdown questionDropdown;
|
||||
public TMP_Dropdown answerDropdown;
|
||||
|
||||
[Header("━━━ BUTONLAR ━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public Button closeButton;
|
||||
|
||||
void Start()
|
||||
{
|
||||
PopulateDropdowns();
|
||||
|
||||
questionDropdown.value = PlayerPrefs.GetInt("QuestionLangID", 1);
|
||||
answerDropdown.value = PlayerPrefs.GetInt("AnswerLangID", 0);
|
||||
|
||||
questionDropdown.RefreshShownValue();
|
||||
answerDropdown.RefreshShownValue();
|
||||
|
||||
closeButton.onClick.AddListener(SaveAndClose);
|
||||
}
|
||||
|
||||
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 SaveAndClose()
|
||||
{
|
||||
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();
|
||||
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
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