Merge pull request 'Fix player name UI and persist name between menu scenes' (#15) from eda-fix-errors into main
Reviewed-on: #15 Reviewed-by: Trubkokrtek <agentdominik707@gmail.com>
This commit was merged in pull request #15.
This commit is contained in:
@@ -31,7 +31,7 @@ public class PlayerNameInput : MonoBehaviour
|
||||
// Keep / ensure background Image
|
||||
var img = nameGO.GetComponent<Image>();
|
||||
if (img == null) img = nameGO.AddComponent<Image>();
|
||||
img.color = new Color(0.08f, 0.10f, 0.20f, 0.92f);
|
||||
img.color = Color.white;
|
||||
|
||||
// Build viewport > (Placeholder + Text) child hierarchy required by TMP_InputField
|
||||
var viewportRT = MakeChild("Text Area", rt);
|
||||
|
||||
22
Assets/Scripts/ukazmeno.cs
Normal file
22
Assets/Scripts/ukazmeno.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class ukazmeno : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text target;
|
||||
[SerializeField] private string prefix = "name: ";
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (target == null)
|
||||
target = GetComponent<TMP_Text>();
|
||||
|
||||
string saved = PlayerPrefs.GetString("PlayerName", "");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(saved) && GameManager.Instance != null)
|
||||
saved = GameManager.Instance.displayName;
|
||||
|
||||
if (target != null)
|
||||
target.text = string.IsNullOrWhiteSpace(saved) ? prefix : prefix + saved;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ukazmeno.cs.meta
Normal file
2
Assets/Scripts/ukazmeno.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d39cd22434ca71a4b820d84bd8bc7e45
|
||||
Reference in New Issue
Block a user