Search Unity

Proper method for Instantiating a NetworkBehaviour in Offline Mode.

Discussion in 'Multiplayer' started by RedRiverStudio, May 29, 2017.

  1. RedRiverStudio

    RedRiverStudio

    Joined:
    Sep 8, 2014
    Posts:
    136
    My levels are procedurally generated, and anything Online is spawned through typical NetworkServer. If I am Offline, and have NetworkBehaviour objects already existing in a scene, they dissappear, which is standard for the class as I understand.

    Without creating entirely new prefabs, and while retaining NetworkBehaviour Inheritance on my objects, what is the proper way to detect Offline Status and bypass the automatic SetActive? Shouldnt NetworkBehaviour be smart enough to know when there is no trace of network connection or networkManager, and treat it as a normal MonoBehaviour?

    Start(){
    if(!isClient)
    SetActive(true);
    }

    ???

    Thanks.
    Ryan
     
  2. RedRiverStudio

    RedRiverStudio

    Joined:
    Sep 8, 2014
    Posts:
    136
    After playing with it a bit, the disable happens even before Awake, so you cant intercept it. When you run OnDisable, it says"GameObject is already being activated or deactivated." so you cant stop it there either.
     
  3. RedRiverStudio

    RedRiverStudio

    Joined:
    Sep 8, 2014
    Posts:
    136
    DungDajHjep likes this.