I've tried adapting the usual single-player loading bar code to one that'll work for multiplayer using PHOTON. Below is the code I've tried.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.SceneManagement;
public class Launcher : MonoBehaviourPunCallbacks
{
[SerializeField]
public Button CreateNameButton;
[SerializeField]
private Slider LoadingSlider;
void Awake()
{
PhotonNetwork.AutomaticallySyncScene = true;
}
public void loadLevels(int sceneIndex)
{
StartCoroutine(loadSelectedScene(sceneIndex));
}
IEnumerator loadSelectedScene(int sceneIndex)
{
AsyncOperation async = PhotonNetwork.LoadLevel(sceneIndex);
while (!async.isDone){
float progress = Mathf.Clamp01(async.progress / .9f);
LoadingSlider.value = async.progress;
yield return null;
}
}
}
I received the error:
Cannot implicitly convert type 'void' to 'UnityEngine.AsyncOperation'