71 lines
1.5 KiB
C#
71 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
using UnityEngine.UI;
|
|
|
|
public class GameUI : MonoBehaviour
|
|
{
|
|
static public int PlayersNumber = 1;
|
|
static GameUI Instance;
|
|
public TMP_Dropdown dropdown; // Referenz auf das Dropdown-Objekt im Unity Inspector
|
|
|
|
void Awake()
|
|
{
|
|
if (Instance == null)
|
|
{
|
|
Instance = this;
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
dropdown.onValueChanged.AddListener(HandleDropdownValueChanged);
|
|
}
|
|
public void HandleInputData(int val)
|
|
{
|
|
if (val == 0)
|
|
{
|
|
Debug.Log("PlayersNumber = 1;");
|
|
PlayersNumber = 1;
|
|
}
|
|
if (val == 1)
|
|
{
|
|
Debug.Log("PlayersNumber = 2;");
|
|
PlayersNumber = 2;
|
|
}
|
|
if (val == 2)
|
|
{
|
|
Debug.Log("PlayersNumber = 4;");
|
|
PlayersNumber = 4;
|
|
}
|
|
if (val == 3)
|
|
{
|
|
Debug.Log("PlayersNumber = 8;");
|
|
PlayersNumber = 8;
|
|
}
|
|
if (val == 4)
|
|
{
|
|
Debug.Log("PlayersNumber = 16;");
|
|
PlayersNumber = 16;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void HandleDropdownValueChanged(int val)
|
|
{
|
|
HandleInputData(val);
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
}
|