From bbc257722b19ef1bb41a58769863cd6f3fe955fc Mon Sep 17 00:00:00 2001 From: Chris Langsenkamp Date: Sun, 7 Jul 2019 02:05:45 -0400 Subject: [PATCH] Added cs to code blocks --- docs/Components/NetworkLobbyManager.md | 4 ++-- docs/Components/NetworkLobbyPlayer.md | 2 +- docs/Concepts/Authority.md | 2 +- docs/Concepts/ClientsServers.md | 6 +++--- docs/Concepts/GameObjects/SpawnObject.md | 12 ++++++------ docs/Concepts/GameObjects/SpawnPlayerCustom.md | 6 +++--- docs/Concepts/VisibilityCustom.md | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/Components/NetworkLobbyManager.md b/docs/Components/NetworkLobbyManager.md index 1d9961ece..c7fcc7dba 100644 --- a/docs/Components/NetworkLobbyManager.md +++ b/docs/Components/NetworkLobbyManager.md @@ -70,7 +70,7 @@ There are two types of player objects with the Network Lobby Manager: ### Server Virtual Methods -``` +```cs public virtual void OnLobbyStartHost() {} public virtual void OnLobbyStopHost() {} @@ -106,7 +106,7 @@ public virtual void OnLobbyServerPlayersReady() ### Client Virtual Methods -``` +```cs public virtual void OnLobbyClientEnter() {} public virtual void OnLobbyClientExit() {} diff --git a/docs/Components/NetworkLobbyPlayer.md b/docs/Components/NetworkLobbyPlayer.md index 757c8ccc0..577fd125d 100644 --- a/docs/Components/NetworkLobbyPlayer.md +++ b/docs/Components/NetworkLobbyPlayer.md @@ -22,7 +22,7 @@ A game object with a Network Lobby Player component must also have a Network Ide ### Client Virtual Methods -``` +```cs public virtual void OnClientEnterLobby() {} public virtual void OnClientExitLobby() {} diff --git a/docs/Concepts/Authority.md b/docs/Concepts/Authority.md index 209ad0af8..689c8ee3d 100644 --- a/docs/Concepts/Authority.md +++ b/docs/Concepts/Authority.md @@ -28,7 +28,7 @@ Assigning authority to a client causes Mirror to call OnStartAuthority() on each If you want non-player game objects to have client authority, you must enable localPlayerAuthority on their Network Identity component. The example below spawns a game object and assigns authority to the client of the player that spawned it. -``` +```cs [Command] void CmdSpawn() { diff --git a/docs/Concepts/ClientsServers.md b/docs/Concepts/ClientsServers.md index 61ec9858e..0c7869c38 100644 --- a/docs/Concepts/ClientsServers.md +++ b/docs/Concepts/ClientsServers.md @@ -8,7 +8,7 @@ For multiplayer games with no dedicated server, one of the players running the g A common pattern for multiplayer games is to have a game object that manages the network state of the game. Below is the start of a NetworkManager script. This script would be attached to a game object that is in the start-up Scene of the game. It has a simple UI and keyboard handling functions that allow the game to be started in different network modes. Before you release your game you should create a more visually appealing menu, with options such as “Start single player game” and “Start multiplayer game”. -``` +```cs using UnityEngine; using Mirror; @@ -47,7 +47,7 @@ public class MyNetworkManager : MonoBehaviour { This basic code calls setup functions to get things going. Below are the simple setup functions for each of the scenarios. These functions create a server, or the right kind of client for each scenario. Note that the remote client assumes the server is on the same machine (127.0.0.1). For a finished game this would be an internet address, or something supplied by the Matchmaking system. -``` +```cs // Create a server and listen on a port public void SetupServer() { @@ -75,7 +75,7 @@ public void SetupLocalClient() The clients in this code register a callback function for the connection event [MsgType.Connect](https://docs.unity3d.com/ScriptReference/Networking.MsgType.Connect.html). This is a built-in message of Mirror that the script invokes when a client connects to a server. In this case, the code for the handler on the client is: -``` +```cs // client function public void OnConnected(NetworkMessage netMsg) { diff --git a/docs/Concepts/GameObjects/SpawnObject.md b/docs/Concepts/GameObjects/SpawnObject.md index 03578bf6b..f62929e54 100644 --- a/docs/Concepts/GameObjects/SpawnObject.md +++ b/docs/Concepts/GameObjects/SpawnObject.md @@ -20,7 +20,7 @@ To spawn game objects without using the Network Manager, you can handle the Pref ### Example: MyNetworkManager -``` +```cs using UnityEngine; using Mirror; @@ -49,7 +49,7 @@ Registering Prefabs ensures that the Asset, so that there is no stalling or load However, for the script to work, you also need to add code for the server. Add this to the MyNetworkManager script: -``` +```cs public void ServerListen() { NetworkServer.RegisterHandler(MsgType.Connect, OnServerConnect); @@ -91,7 +91,7 @@ For more advanced uses, such as object pools or dynamically created Assets, you If the game object has a network state like synchronized variables, then that state is synchronized with the spawn message. In the following example, this script is attached to the tree Prefab: -``` +```cs using UnityEngine; using Mirror; @@ -109,7 +109,7 @@ class Tree : NetworkBehaviour With this script attached, you can change the `numLeaves` variable and modify the `SpawnTrees` function to see it accurately reflected on the client: -``` +```cs void SpawnTrees() { int x = 0; @@ -179,7 +179,7 @@ Objects spawned with client authority must have `LocalPlayerAuthority` set in th For example, the tree spawn example above can be modified to allow the tree to have client authority like this (note that we now need to pass in a NetworkConnection game object for the owning client’s connection): -``` +```cs void SpawnTrees(NetworkConnection conn) { int x = 0; @@ -196,7 +196,7 @@ void SpawnTrees(NetworkConnection conn) The Tree script can now be modified to send a command to the server: -``` +```cs public override void OnStartAuthority() { CmdMessageFromTree("Tree with " + numLeaves + " reporting in"); diff --git a/docs/Concepts/GameObjects/SpawnPlayerCustom.md b/docs/Concepts/GameObjects/SpawnPlayerCustom.md index e2c9d096a..63ff16151 100644 --- a/docs/Concepts/GameObjects/SpawnPlayerCustom.md +++ b/docs/Concepts/GameObjects/SpawnPlayerCustom.md @@ -8,7 +8,7 @@ When the Network Manager adds a player, it also instantiates a game object from The example below customizes the color of a player. First, add the color script to the player prefab: -``` +```cs using UnityEngine; using Mirror; class Player : NetworkBehaviour @@ -20,7 +20,7 @@ class Player : NetworkBehaviour Next, create a NetworkManager to handle spawning. -``` +```cs using UnityEngine; using Mirror; @@ -53,7 +53,7 @@ To replace the player game object for a connection, use NetworkServer.ReplacePla You can also use `ReplacePlayerForConnection` to respawn a player after their game object is destroyed. In some cases it is better to just disable a game object and reset its game attributes on respawn. The following code sample demonstrates how to actually replace the destroyed game object with a new game object: -``` +```cs class GameManager { public void PlayerWasKilled(Player player) diff --git a/docs/Concepts/VisibilityCustom.md b/docs/Concepts/VisibilityCustom.md index dc8234dc0..2b61774a3 100644 --- a/docs/Concepts/VisibilityCustom.md +++ b/docs/Concepts/VisibilityCustom.md @@ -19,7 +19,7 @@ On the `NetworkBehaviour`class (which your networked scripts inherit from), ther You can check whether any given networked game object is a player by checking if its `NetworkIdentity` has a valid connectionToClient. For example: -``` +```cs var hits = Physics.OverlapSphere(transform.position, visRange); foreach (var hit in hits) {