Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Discussion Your script should either check if it is null or you should not destroy the object. Not found object

Discussion in 'Unity Transport' started by langqing429, Nov 12, 2022.

  1. langqing429

    langqing429

    Joined:
    Aug 6, 2022
    Posts:
    4
    I'm having trouble with lobby and relay. The problem is when I create lobby as a host and then start the game and I leave from the game scene and then I create lobby again and the error pop up that the scripts in the lobby canvas ---
    The object of type 'MainLobby' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.

    how could I fix it. When I check the canvas, it is still there. However, the network host started but I have to manually click spawn on the network object.
     
  2. langqing429

    langqing429

    Joined:
    Aug 6, 2022
    Posts:
    4
    I fix it using
    Code (CSharp):
    1. if(!NetworkObject.IsSpawned) NetworkObject.Spawn();
    But I am not sure it is a good idea.