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
71
Assets/Scripts/3.5/ModLeaderboard.cs
Normal file
71
Assets/Scripts/3.5/ModLeaderboard.cs
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
public class ModLeaderboard : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ UI SLOTS (10 satır) ━━━━━━━━━━━━━━━")]
|
||||
public TMP_Text[] rows;
|
||||
[Header("━━━ BUTONLAR ━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public Button mainMenuButton;
|
||||
[Header("━━━ MOD AYARI ━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public string scoreKey = "GalaxyScore";
|
||||
//
|
||||
// Her mod için scoreKey değeri:
|
||||
// ─────────────────────────────
|
||||
// Galaxy Modu → "GalaxyScore"
|
||||
// Time Modu → "TimeScore"
|
||||
// Classic Modu → "ClassicScore"
|
||||
// Challenge Modu → "ChallengeScore"
|
||||
private readonly string[] botNames =
|
||||
{
|
||||
"ShadowWolf", "CrystalMind", "NightHunter",
|
||||
"BlueVortex", "IronSoul", "PixelGhost",
|
||||
"SilverClaw", "MegaCore", "NeonBlade", "DarkNova"
|
||||
};
|
||||
class LBEntry
|
||||
{
|
||||
public string name;
|
||||
public int score;
|
||||
public LBEntry(string n, int s) { name = n; score = s; }
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
GenerateLeaderboard();
|
||||
if (mainMenuButton != null)
|
||||
mainMenuButton.onClick.AddListener(() =>
|
||||
SceneManager.LoadScene("Anamen"));
|
||||
}
|
||||
void GenerateLeaderboard()
|
||||
{
|
||||
List<LBEntry> list = new List<LBEntry>();
|
||||
int botLimit = Mathf.Min(rows.Length - 1, botNames.Length);
|
||||
for (int i = 0; i < botLimit; i++)
|
||||
list.Add(new LBEntry(botNames[i], Random.Range(3000, 12000)));
|
||||
string highKey = scoreKey + "_High";
|
||||
int lastScore = PlayerPrefs.GetInt(scoreKey, 0);
|
||||
int highScore = PlayerPrefs.GetInt(highKey, 0);
|
||||
if (lastScore > highScore)
|
||||
{
|
||||
highScore = lastScore;
|
||||
PlayerPrefs.SetInt(highKey, highScore);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
list.Add(new LBEntry("YOU", highScore));
|
||||
list.Sort((a, b) => b.score.CompareTo(a.score));
|
||||
for (int i = 0; i < rows.Length; i++)
|
||||
{
|
||||
if (i < list.Count)
|
||||
{
|
||||
rows[i].text = list[i].name == "YOU"
|
||||
? $"<color=#00FF00>{i + 1}. {list[i].name} - {list[i].score}</color>"
|
||||
: $"{i + 1}. {list[i].name} - {list[i].score}";
|
||||
}
|
||||
else
|
||||
{
|
||||
rows[i].text = $"{i + 1}. ---";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/3.5/ModLeaderboard.cs.meta
Normal file
2
Assets/Scripts/3.5/ModLeaderboard.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 85e3141c0f135d94e9c099c2b7f5da74
|
||||
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"
|
||||
};
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/3.5/ModSelectLanguageSettings.cs.meta
Normal file
2
Assets/Scripts/3.5/ModSelectLanguageSettings.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3eb2fcea3bc7c8b41b1842e752ce2168
|
||||
151
Assets/Scripts/3.5/ModWordListScreen.cs
Normal file
151
Assets/Scripts/3.5/ModWordListScreen.cs
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
using UnityEngine;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
public class ModWordListScreen : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ LEVEL TXT DOSYALARI (6 DİL) ━━━━━━━")]
|
||||
public TextAsset[] levelFiles;
|
||||
|
||||
[Header("━━━ 20 KELİME SLOTU ━━━━━━━━━━━━━━━━━━━")]
|
||||
public TMP_Text[] wordTexts;
|
||||
|
||||
[Header("━━━ SAYFA BİLGİSİ ━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public TMP_Text pageInfoText;
|
||||
|
||||
[Header("━━━ BUTONLAR ━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public Button nextButton;
|
||||
public Button closeButton;
|
||||
|
||||
[Header("━━━ AUDIO ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public AudioSource audioSource;
|
||||
public AudioClip clickSound;
|
||||
|
||||
private string questionLang;
|
||||
private string answerLang;
|
||||
|
||||
private int currentLevelIndex = 0;
|
||||
private int currentPageIndex = 0;
|
||||
|
||||
private int PAGE_SIZE;
|
||||
private List<WordPair> words = new();
|
||||
|
||||
private int MaxPageCount => (words.Count == 0) ? 1 : (words.Count - 1) / PAGE_SIZE + 1;
|
||||
|
||||
// ============================================================
|
||||
void Awake()
|
||||
{
|
||||
PAGE_SIZE = (wordTexts != null && wordTexts.Length > 0) ? wordTexts.Length : 20;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
nextButton.onClick.AddListener(() => { PlayClick(); NextPage(); });
|
||||
closeButton.onClick.AddListener(() => { PlayClick(); gameObject.SetActive(false); });
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
if (PAGE_SIZE == 0) return;
|
||||
|
||||
questionLang = PlayerPrefs.GetString("QuestionLangCode", "en");
|
||||
answerLang = PlayerPrefs.GetString("AnswerLangCode", "tr");
|
||||
|
||||
currentLevelIndex = 0;
|
||||
currentPageIndex = 0;
|
||||
|
||||
LoadLevel(currentLevelIndex);
|
||||
ShowPage();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void PlayClick()
|
||||
{
|
||||
if (audioSource && clickSound)
|
||||
audioSource.PlayOneShot(clickSound);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void LoadLevel(int index)
|
||||
{
|
||||
words.Clear();
|
||||
currentPageIndex = 0;
|
||||
|
||||
if (index < 0 || index >= levelFiles.Length)
|
||||
{
|
||||
currentLevelIndex = 0;
|
||||
LoadLevel(0);
|
||||
return;
|
||||
}
|
||||
|
||||
TextAsset txt = levelFiles[index];
|
||||
if (txt == null) return;
|
||||
|
||||
string[] lines = txt.text.Split(
|
||||
new[] { '\n', '\r' },
|
||||
StringSplitOptions.RemoveEmptyEntries
|
||||
);
|
||||
|
||||
foreach (string raw in lines)
|
||||
{
|
||||
string[] p = raw.Trim().Split(',');
|
||||
if (p.Length < 6) continue;
|
||||
|
||||
words.Add(new WordPair(
|
||||
p[0].Trim(), p[1].Trim(),
|
||||
p[2].Trim(), p[3].Trim(),
|
||||
p[4].Trim(), p[5].Trim()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void ShowPage()
|
||||
{
|
||||
for (int i = 0; i < wordTexts.Length; i++)
|
||||
wordTexts[i].text = "";
|
||||
|
||||
int start = currentPageIndex * PAGE_SIZE;
|
||||
|
||||
for (int i = 0; i < PAGE_SIZE; i++)
|
||||
{
|
||||
int index = start + i;
|
||||
if (index >= words.Count || i >= wordTexts.Length) break;
|
||||
|
||||
WordPair w = words[index];
|
||||
wordTexts[i].text = $"{w.GetByCode(questionLang)} → {w.GetByCode(answerLang)}";
|
||||
}
|
||||
|
||||
UpdatePageInfo();
|
||||
}
|
||||
|
||||
void UpdatePageInfo()
|
||||
{
|
||||
pageInfoText.text = $"Page {currentPageIndex + 1}/{MaxPageCount}";
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
void NextPage()
|
||||
{
|
||||
if (currentPageIndex < MaxPageCount - 1)
|
||||
{
|
||||
currentPageIndex++;
|
||||
ShowPage();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentLevelIndex < levelFiles.Length - 1)
|
||||
{
|
||||
currentLevelIndex++;
|
||||
LoadLevel(currentLevelIndex);
|
||||
ShowPage();
|
||||
return;
|
||||
}
|
||||
|
||||
currentLevelIndex = 0;
|
||||
LoadLevel(0);
|
||||
ShowPage();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/3.5/ModWordListScreen.cs.meta
Normal file
2
Assets/Scripts/3.5/ModWordListScreen.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7d689475375cc646bbae90bac8ed87a
|
||||
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();
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/3.5/MusicManager.cs.meta
Normal file
2
Assets/Scripts/3.5/MusicManager.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5ee7bf0e8dcf55d49b30097a95df3c81
|
||||
8
Assets/Scripts/3.5/Prefabs.meta
Normal file
8
Assets/Scripts/3.5/Prefabs.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c7231500a58028042884bbf82d67a21d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
202
Assets/Scripts/3.5/Prefabs/ModSelectManager.cs
Normal file
202
Assets/Scripts/3.5/Prefabs/ModSelectManager.cs
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using TMPro;
|
||||
|
||||
[System.Serializable]
|
||||
public class ModData
|
||||
{
|
||||
public Sprite modSprite;
|
||||
public string sceneName;
|
||||
}
|
||||
|
||||
public class ModSelectManager : MonoBehaviour
|
||||
{
|
||||
[Header("━━━ MODLAR ━━━━━━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public ModData[] mods;
|
||||
|
||||
[Header("━━━ KART BOYUTLARI ━━━━━━━━━━━━━━━━━━━━")]
|
||||
public float cardWidth = 900f;
|
||||
public float cardHeight = 500f;
|
||||
public float spacing = 40f;
|
||||
|
||||
[Header("━━━ PLAY BUTTON ━━━━━━━━━━━━━━━━━━━━━━━")]
|
||||
public string playButtonText = "PLAY";
|
||||
public float playButtonWidth = 400f;
|
||||
public float playButtonHeight = 100f;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Canvas canvas = FindAnyObjectByType<Canvas>();
|
||||
|
||||
if (canvas == null)
|
||||
{
|
||||
GameObject canvasObj = new GameObject("Canvas");
|
||||
canvas = canvasObj.AddComponent<Canvas>();
|
||||
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
||||
|
||||
CanvasScaler scaler = canvasObj.AddComponent<CanvasScaler>();
|
||||
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
||||
scaler.referenceResolution = new Vector2(1080, 1920);
|
||||
scaler.screenMatchMode = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
|
||||
scaler.matchWidthOrHeight = 0.5f;
|
||||
|
||||
canvasObj.AddComponent<GraphicRaycaster>();
|
||||
}
|
||||
|
||||
GameObject oldScroll = GameObject.Find("ModScrollView");
|
||||
|
||||
if (oldScroll != null)
|
||||
Destroy(oldScroll);
|
||||
|
||||
GameObject scrollObj = new GameObject("ModScrollView");
|
||||
scrollObj.transform.SetParent(canvas.transform, false);
|
||||
|
||||
RectTransform scrollRect = scrollObj.AddComponent<RectTransform>();
|
||||
scrollRect.anchorMin = Vector2.zero;
|
||||
scrollRect.anchorMax = Vector2.one;
|
||||
scrollRect.offsetMin = Vector2.zero;
|
||||
scrollRect.offsetMax = Vector2.zero;
|
||||
|
||||
ScrollRect scroll = scrollObj.AddComponent<ScrollRect>();
|
||||
scroll.horizontal = false;
|
||||
scroll.vertical = true;
|
||||
scroll.movementType = ScrollRect.MovementType.Elastic;
|
||||
scroll.elasticity = 0.12f;
|
||||
scroll.inertia = true;
|
||||
scroll.decelerationRate = 0.135f;
|
||||
scroll.scrollSensitivity = 30f;
|
||||
|
||||
GameObject viewportObj = new GameObject("Viewport");
|
||||
viewportObj.transform.SetParent(scrollObj.transform, false);
|
||||
|
||||
RectTransform viewportRect = viewportObj.AddComponent<RectTransform>();
|
||||
viewportRect.anchorMin = Vector2.zero;
|
||||
viewportRect.anchorMax = Vector2.one;
|
||||
viewportRect.offsetMin = Vector2.zero;
|
||||
viewportRect.offsetMax = Vector2.zero;
|
||||
|
||||
Image viewportImage = viewportObj.AddComponent<Image>();
|
||||
viewportImage.color = new Color(0f, 0f, 0f, 0f);
|
||||
|
||||
Mask mask = viewportObj.AddComponent<Mask>();
|
||||
mask.showMaskGraphic = false;
|
||||
|
||||
GameObject contentObj = new GameObject("Content");
|
||||
contentObj.transform.SetParent(viewportObj.transform, false);
|
||||
|
||||
RectTransform contentRect = contentObj.AddComponent<RectTransform>();
|
||||
contentRect.anchorMin = new Vector2(0f, 1f);
|
||||
contentRect.anchorMax = new Vector2(1f, 1f);
|
||||
contentRect.pivot = new Vector2(0.5f, 1f);
|
||||
contentRect.anchoredPosition = Vector2.zero;
|
||||
contentRect.sizeDelta = Vector2.zero;
|
||||
|
||||
VerticalLayoutGroup vlg = contentObj.AddComponent<VerticalLayoutGroup>();
|
||||
vlg.spacing = spacing;
|
||||
vlg.padding = new RectOffset(50, 50, 50, 50);
|
||||
vlg.childAlignment = TextAnchor.UpperCenter;
|
||||
vlg.childControlWidth = false;
|
||||
vlg.childControlHeight = false;
|
||||
vlg.childForceExpandWidth = false;
|
||||
vlg.childForceExpandHeight = false;
|
||||
|
||||
ContentSizeFitter csf = contentObj.AddComponent<ContentSizeFitter>();
|
||||
csf.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
csf.horizontalFit = ContentSizeFitter.FitMode.Unconstrained;
|
||||
|
||||
scroll.viewport = viewportRect;
|
||||
scroll.content = contentRect;
|
||||
|
||||
if (mods == null || mods.Length == 0)
|
||||
{
|
||||
Debug.LogWarning("ModSelectManager: mods listesi boş.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (ModData mod in mods)
|
||||
{
|
||||
if (mod == null)
|
||||
continue;
|
||||
|
||||
GameObject card = new GameObject("ModCard");
|
||||
card.transform.SetParent(contentObj.transform, false);
|
||||
|
||||
RectTransform cardRect = card.AddComponent<RectTransform>();
|
||||
cardRect.sizeDelta = new Vector2(cardWidth, cardHeight);
|
||||
|
||||
LayoutElement cardLayout = card.AddComponent<LayoutElement>();
|
||||
cardLayout.preferredWidth = cardWidth;
|
||||
cardLayout.preferredHeight = cardHeight;
|
||||
cardLayout.minWidth = cardWidth;
|
||||
cardLayout.minHeight = cardHeight;
|
||||
cardLayout.flexibleWidth = 0f;
|
||||
cardLayout.flexibleHeight = 0f;
|
||||
|
||||
Image cardImg = card.AddComponent<Image>();
|
||||
cardImg.color = new Color(0.1f, 0.1f, 0.2f, 1f);
|
||||
|
||||
GameObject imgObj = new GameObject("ModImage");
|
||||
imgObj.transform.SetParent(card.transform, false);
|
||||
|
||||
RectTransform imgRect = imgObj.AddComponent<RectTransform>();
|
||||
imgRect.anchorMin = Vector2.zero;
|
||||
imgRect.anchorMax = Vector2.one;
|
||||
imgRect.offsetMin = new Vector2(0f, 120f);
|
||||
imgRect.offsetMax = Vector2.zero;
|
||||
|
||||
Image modImg = imgObj.AddComponent<Image>();
|
||||
|
||||
if (mod.modSprite != null)
|
||||
modImg.sprite = mod.modSprite;
|
||||
|
||||
modImg.preserveAspect = true;
|
||||
modImg.raycastTarget = false;
|
||||
|
||||
GameObject btnObj = new GameObject("PlayButton");
|
||||
btnObj.transform.SetParent(card.transform, false);
|
||||
|
||||
RectTransform btnRect = btnObj.AddComponent<RectTransform>();
|
||||
btnRect.anchorMin = new Vector2(0.5f, 0f);
|
||||
btnRect.anchorMax = new Vector2(0.5f, 0f);
|
||||
btnRect.pivot = new Vector2(0.5f, 0f);
|
||||
btnRect.sizeDelta = new Vector2(playButtonWidth, playButtonHeight);
|
||||
btnRect.anchoredPosition = new Vector2(0f, 10f);
|
||||
|
||||
Image btnImg = btnObj.AddComponent<Image>();
|
||||
btnImg.color = new Color(0.1f, 0.7f, 0.2f, 1f);
|
||||
|
||||
Button btn = btnObj.AddComponent<Button>();
|
||||
|
||||
GameObject txtObj = new GameObject("Text");
|
||||
txtObj.transform.SetParent(btnObj.transform, false);
|
||||
|
||||
RectTransform txtRect = txtObj.AddComponent<RectTransform>();
|
||||
txtRect.anchorMin = Vector2.zero;
|
||||
txtRect.anchorMax = Vector2.one;
|
||||
txtRect.offsetMin = Vector2.zero;
|
||||
txtRect.offsetMax = Vector2.zero;
|
||||
|
||||
TextMeshProUGUI tmp = txtObj.AddComponent<TextMeshProUGUI>();
|
||||
tmp.text = playButtonText;
|
||||
tmp.fontSize = 50f;
|
||||
tmp.alignment = TextAlignmentOptions.Center;
|
||||
tmp.color = Color.white;
|
||||
tmp.raycastTarget = false;
|
||||
|
||||
string sceneName = mod.sceneName;
|
||||
|
||||
btn.onClick.RemoveAllListeners();
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(sceneName))
|
||||
{
|
||||
Debug.LogWarning("ModSelectManager: sceneName boş.");
|
||||
return;
|
||||
}
|
||||
|
||||
SceneManager.LoadScene(sceneName);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/3.5/Prefabs/ModSelectManager.cs.meta
Normal file
2
Assets/Scripts/3.5/Prefabs/ModSelectManager.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a2b4db01ffdbb4c418ce084b87659f0f
|
||||
19
Assets/Scripts/3.5/SoundManager.cs
Normal file
19
Assets/Scripts/3.5/SoundManager.cs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
using UnityEngine;
|
||||
|
||||
public class SoundManager : MonoBehaviour
|
||||
{
|
||||
public static SoundManager instance;
|
||||
public AudioSource audioSource;
|
||||
public AudioClip clickSound;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void PlayClick()
|
||||
{
|
||||
if (audioSource && clickSound)
|
||||
audioSource.PlayOneShot(clickSound);
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/3.5/SoundManager.cs.meta
Normal file
2
Assets/Scripts/3.5/SoundManager.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1a1f2461a1242e640a3493747a8569fe
|
||||
Loading…
Add table
Add a link
Reference in a new issue