public static void Dispose() { if (!Initialized) { Error("Not initialized."); return; } if (IsClient) { ShutdownClient("Client process ended."); } if (IsServer) { ShutdownServer("Server process ended."); } AppID = null; Tracker.Reset(); Tracker = null; Prefabs = null; Playback.Dispose(); Playback = null; Initialized = false; }
/// <summary> /// Initializes the JNet system. This must be called before any other JNet functionality can be used. /// </summary> /// <param name="appID">The application unique indentifier, must not be null or blank. Any leading or trailing whitespace will be trimmed.</param> /// <param name="updateClassMap">If false, the class map for NetBehaviours is not refreshed, which can lead to netcode failing to work. Only used for unit testing pruposes internally.</param> public static void Init(string appID, bool includeSceneObjects = true) { if (Initialized) { Error("Already initialized."); return; } // Validate the app id. if (string.IsNullOrWhiteSpace(appID)) { Error("App ID supplied is null or blank, invalid. JNet has not been initialized."); return; } JNet.EnableSceneObjectNetworking = includeSceneObjects; AppID = appID.Trim(); Tracker = new WorldStateTracker(); Prefabs = new NetObject[ushort.MaxValue + 1]; Playback = new JNetPlayback(); NetBehaviour.UpdateClassMap(); Initialized = true; }