prepinani scen
This commit is contained in:
31
Assets/Scripts/ZmenScenu.cs
Normal file
31
Assets/Scripts/ZmenScenu.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI; // Nutné pro práci s UI komponentami
|
||||
|
||||
public class CudlikZmenaSceny : MonoBehaviour
|
||||
{
|
||||
// Toto políèko uvidíš v Inspectoru pøímo u tlaèítka
|
||||
[SerializeField] private string nazevCiloveSceny;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Automaticky øekne tlaèítku, co má dìlat, když na nìj klikneš
|
||||
Button btn = GetComponent<Button>();
|
||||
if (btn != null)
|
||||
{
|
||||
btn.onClick.AddListener(Prejdi);
|
||||
}
|
||||
}
|
||||
|
||||
void Prejdi()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(nazevCiloveSceny))
|
||||
{
|
||||
SceneManager.LoadScene(nazevCiloveSceny);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Zapomnìl jsi vyplnit název scény na objektu: " + gameObject.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user