Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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.