Merge branch 'dev-ali' into dev-main
commit
54b3f9ae63
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerName : MonoBehaviour
|
||||
{
|
||||
public TMP_InputField inputField; // Reference to the InputField
|
||||
public Button submitButton; // Reference to the Button
|
||||
public GameObject Panel;
|
||||
public static event Action nameEntered;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Starter();
|
||||
}
|
||||
void Starter()
|
||||
{
|
||||
if (PlayerPrefs.GetInt("PlayerNameSaved") == 0)
|
||||
{
|
||||
Panel.SetActive(true);
|
||||
|
||||
submitButton.interactable = false;
|
||||
|
||||
// Add a listener to detect input changes
|
||||
inputField.onValueChanged.AddListener(delegate { ToggleButtonState(); });
|
||||
}
|
||||
}
|
||||
void ToggleButtonState()
|
||||
{
|
||||
// Enable the button if input is not empty, disable otherwise
|
||||
submitButton.interactable = !string.IsNullOrEmpty(inputField.text);
|
||||
}
|
||||
public void SaveName()
|
||||
{
|
||||
PlayerPrefs.SetInt("PlayerNameSaved", 1);
|
||||
Debug.Log("Name that is saved is: " + inputField.text.ToString());
|
||||
PlayerPrefs.SetString("PlayerName", inputField.text.ToString());
|
||||
nameEntered?.Invoke();
|
||||
Panel.SetActive(false);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b6c7db1e50e6134f912900d592c71e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue