Home > Net >  ERROR message. Type or namespace definition, or end-of-file expected
ERROR message. Type or namespace definition, or end-of-file expected

Time:08-01

Help me. I am attempting to build a multiplayer game in in unity using photon cloud. i am using the free asset store extension to connect to the server. however, no matter what i do, this error shows:

Type or namespace definition, or end-of-file expected

I neither understand what it means nor know what to do about it. can someone help me, please?

my code is this:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.SceneManagement;

public class LoadServer : MonoBehaviourPunCallbacks
{
    
    private void Start()
    {
        PhotonNetwork.ConnectUsingSettings();
    }

    
    public override void OnConnectedToMaster()
    {
        PhotonNetwork.JoinLobby();
    }

    public override void OnJoinedLobby();
    {
        SceneManager.LoadScene("Lobby");
    }
}

CodePudding user response:

You have a semicolon after OnJoinedLobby() which is not valid C# syntax.

As a point of advice, use an editor with syntax highlighting like VS Code or Visual Studio. It will detect issues like this for you

CodePudding user response:

maybe get rid of the semicolon on public override void OnJoinedLobby();

thanks! @DeveNuub

  • Related