- Home /
Question by
alistairhgrant · Apr 17, 2019 at 03:00 PM ·
menuloadlevelstartload scenesplit-screen
split-screen 'ready up' game start screen
I am trying to make a split-screen local multiplayer ready up/start screen that requires both players to press the button for the game to begin and the level/scene to load. I have the menu screen set up and working using some code from Brackey's but could do with some guidance of how to set up the requirement for two players pressing it, it currently starts loading with one click. I am not a programmer so any help would be massively appreciated.
Thanks, Ali
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class LevelLoader : MonoBehaviour
{
public GameObject loadingScreen;
public Slider slider;
public Text progressText;
public void LoadLevel (int sceneIndex)
{
StartCoroutine(LoadAsynchronously(sceneIndex));
}
IEnumerator LoadAsynchronously (int sceneIndex)
{
AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);
loadingScreen.SetActive(true);
while (!operation.isDone)
{
float progress = Mathf.Clamp01(operation.progress / .9f);
slider.value = progress;
progressText.text = progress * 100f + "%";
yield return null;
}
}
}
menu1.jpg
(233.7 kB)
Comment