Search Unity

Question help how to fix this

Discussion in 'Multiplayer' started by sxcr3am, Apr 3, 2022.

  1. sxcr3am

    sxcr3am

    Joined:
    Mar 29, 2022
    Posts:
    2
    Code (CSharp):
    1. using UnityEngine;
    2. using Photon.Pun;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class Loading : MonoBehaviour
    6. {
    7.    
    8.     void Start()
    9.     {
    10.         PhotonNetwork.ConnectUsingSettings();
    11.     }
    12.  
    13.     public override void OnConnectedToMaster()
    14.     {
    15.         Debug.Log("Connected");
    16.         SceneManager.LoadScene("Lobby");
    17.     }
    18. }
    Assets\Loading.cs(13,26): error CS0115: 'Loading.OnConnectedToMaster()': no suitable method found to override
     
  2. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
  3. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,068
    You need to implement IConnectionCallbacks and register for the callbacks. MonoBehaviourPunCallbacks does that for you. If you override OnEnable or OnDisable, make sure to call the base method.
     
    Punfish likes this.