Class Network
Manages Netick and its sandboxes, and is used to start and shut down Netick.
[HideInInspector]
[DisallowMultipleComponent]
public sealed class Network : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourNetwork
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.transformComponent.gameObjectComponent.tagObject.GetInstanceID()Object.GetHashCode()Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
- Extension Methods
Fields
Version
public const string Version = "0.12.22"
Field Value
Properties
Config
public static NetickConfig Config { get; }
Property Value
Instance
public static Network Instance { get; }
Property Value
IsHeadless
public static bool IsHeadless { get; }
Property Value
IsRunning
public static bool IsRunning { get; }
Property Value
Sandboxes
public static IReadOnlyList<NetworkSandbox> Sandboxes { get; }
Property Value
StartMode
public static StartMode StartMode { get; }
Property Value
Methods
Focus(NetworkSandbox)
Focus on a specific sandbox.
public static void Focus(NetworkSandbox sandbox)
Parameters
sandbox
NetworkSandboxThe sandbox to focus on.
Init(NetickConfig)
Initializes Netick. This is automatically called when you start Netick.
If you don't provide a NetickConfig, Netick will use the default config, which can be modified/found in (Netick -> Settings).
public static void Init(NetickConfig config = null)
Parameters
config
NetickConfig
Launch(StartMode, LaunchData)
public static Network.LaunchResults Launch(StartMode mode, LaunchData launchData)
Parameters
mode
StartModelaunchData
LaunchData
Returns
Shutdown(bool)
Shuts down Netick and destroys all sandboxes. The shutdown will occur in the next frame. For immediate shutdown, use: ShutdownImmediately(bool)
public static void Shutdown(bool destroyAllNetworkObjects = false)
Parameters
destroyAllNetworkObjects
bool
ShutdownImmediately(bool)
Shuts down Netick and destroys all sandboxes immediately.
public static void ShutdownImmediately(bool destroyAllNetworkObjects = false)
Parameters
destroyAllNetworkObjects
bool
ShutdownSandbox(NetworkSandbox, bool)
Shuts down a specific sandbox.
public static void ShutdownSandbox(NetworkSandbox sandbox, bool destroyAllNetworkObjects = false)
Parameters
sandbox
NetworkSandboxThe sandbox to shut down.
destroyAllNetworkObjects
bool
StartAsClient(NetworkTransportProvider, int, GameObject)
Starts Netick as a client.
public static NetworkSandbox StartAsClient(NetworkTransportProvider transportProvider, int port, GameObject sandboxPrefab = null)
Parameters
transportProvider
NetworkTransportProviderport
intsandboxPrefab
GameObject
Returns
- NetworkSandbox
The sandbox representing the client
StartAsHost(NetworkTransportProvider, int, GameObject)
Starts Netick as a host.
public static NetworkSandbox StartAsHost(NetworkTransportProvider transportProvider, int port, GameObject sandboxPrefab = null)
Parameters
transportProvider
NetworkTransportProviderport
intNetwork port.
sandboxPrefab
GameObject
Returns
- NetworkSandbox
The sandbox representing the server
StartAsMultiplePeers(NetworkTransportProvider, int, GameObject, bool, bool, int)
Starts multiple peers together.
public static Network.LaunchResults StartAsMultiplePeers(NetworkTransportProvider transportProvider, int port, GameObject sandboxPrefab = null, bool startAServer = true, bool startServerAsHost = true, int numOfClients = 1)
Parameters
transportProvider
NetworkTransportProviderport
intsandboxPrefab
GameObjectstartAServer
boolShould we start a server too.
startServerAsHost
boolnumOfClients
intNumber of clients to create.
Returns
StartAsServer(NetworkTransportProvider, int, GameObject)
Starts Netick as a server.
public static NetworkSandbox StartAsServer(NetworkTransportProvider transportProvider, int port, GameObject sandboxPrefab = null)
Parameters
transportProvider
NetworkTransportProviderport
intNetwork port.
sandboxPrefab
GameObject
Returns
- NetworkSandbox
The sandbox representing the server
StartAsServerAndClient(NetworkTransportProvider, int, GameObject, int)
Starts both a client (or clients) and a server.
[Obsolete("This is obsolete. Use StartAsMultiplePeers instead.")]
public static Network.LaunchResults StartAsServerAndClient(NetworkTransportProvider transportProvider, int serverPort, GameObject sandboxPrefab = null, int numOfClients = 1)
Parameters
transportProvider
NetworkTransportProviderserverPort
intNetwork port.
sandboxPrefab
GameObjectnumOfClients
intNumber of client sandboxes to create.
Returns
StartAsSinglePlayer(GameObject)
Starts Netick in single player mode.
public static NetworkSandbox StartAsSinglePlayer(GameObject sandboxPrefab = null)
Parameters
sandboxPrefab
GameObject
Returns
- NetworkSandbox
The sandbox representing the server