├── .gitignore ├── Assets ├── Packages.meta ├── Packages │ ├── UNetworkManager.meta │ └── UNetworkManager │ │ ├── UNetworkManager.cs │ │ ├── UNetworkManager.cs.meta │ │ ├── UNetworkManagerSettings.cs │ │ └── UNetworkManagerSettings.cs.meta ├── SendReceiveMessageSample.cs ├── SendReceiveMessageSample.cs.meta ├── SendReceiveMessageSample.unity ├── SendReceiveMessageSample.unity.meta ├── SyncListSample.cs ├── SyncListSample.cs.meta ├── SyncListSample.unity ├── SyncListSample.unity.meta ├── UNetworkManagerSample.cs ├── UNetworkManagerSample.cs.meta ├── UNetworkManagerSample.unity ├── UNetworkManagerSample.unity.meta ├── csc.rsp └── csc.rsp.meta ├── LICENSE ├── Logs └── Packages-Update.log ├── Packages └── manifest.json ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset ├── VFXManager.asset └── XRSettings.asset ├── README.md ├── UNetworkManager.unitypackage └── screenshot.png /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk -------------------------------------------------------------------------------- /Assets/Packages.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d408207d2865a8a4e9740a7a590f039e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Packages/UNetworkManager.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0b382aee2c6a304db60b133068ac8de 3 | folderAsset: yes 4 | timeCreated: 1509356165 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Packages/UNetworkManager/UNetworkManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | using UnityEngine.Networking; 6 | 7 | public class UNetworkManager : NetworkManager 8 | { 9 | #region Enum 10 | 11 | public enum UNetType 12 | { 13 | Server = 0, 14 | Host = 1, 15 | Client = 2, 16 | None = 3, 17 | } 18 | 19 | #endregion Enum 20 | 21 | #region Field 22 | 23 | public bool autoStart; 24 | public UNetType autoStartType; 25 | public float autoStartIntervalTimeSec = 15; 26 | protected float previousAutoStartTimeSec = 0; 27 | 28 | #region Status 29 | 30 | public struct StatusMessage 31 | { 32 | public DateTime time; 33 | public string message; 34 | } 35 | 36 | public int statusMessagesCount = 10; 37 | 38 | public List StatusMessages 39 | { 40 | get; 41 | protected set; 42 | } 43 | 44 | #endregion Status 45 | 46 | #region Event 47 | 48 | [Serializable] 49 | public class NetworkConnectionEvent : UnityEvent { } 50 | 51 | public UnityEvent startServerEvent; 52 | public UnityEvent stopServerEvent; 53 | public NetworkConnectionEvent serverConnectEvent; 54 | public NetworkConnectionEvent serverDisconnectEvent; 55 | public NetworkConnectionEvent serverErrorEvent; 56 | 57 | public UnityEvent startHostEvent; 58 | public UnityEvent stopHostEvent; 59 | 60 | public UnityEvent startClientEvent; 61 | public UnityEvent stopClientEvent; 62 | public NetworkConnectionEvent clientConnectEvent; 63 | public NetworkConnectionEvent clientDisconnectEvent; 64 | public NetworkConnectionEvent clientErrorEvent; 65 | 66 | #endregion Event 67 | 68 | #endregion Field 69 | 70 | #region Property 71 | 72 | public static new UNetworkManager singleton 73 | { 74 | get { return (UNetworkManager)NetworkManager.singleton; } 75 | } 76 | 77 | public UNetType NetworkType { get; protected set; } 78 | 79 | public bool IsConnectedClient { get; protected set; } 80 | 81 | public float AutoStartIntervalTick 82 | { get { return this.autoStartIntervalTimeSec 83 | - (Time.timeSinceLevelLoad - this.previousAutoStartTimeSec); } } 84 | 85 | #endregion Propery 86 | 87 | #region Method 88 | 89 | protected virtual void OnEnable() 90 | { 91 | // NOTE: 92 | // It should not to initialize something in Awake. 93 | // Because based NetworkManager use Awake to initialize singleton logic. 94 | // Awake is not able to override. 95 | 96 | this.NetworkType = UNetType.None; 97 | 98 | this.StatusMessages = new List(); 99 | 100 | AddStatusMessage("…"); 101 | } 102 | 103 | protected virtual void Start() 104 | { 105 | Start(true); 106 | } 107 | 108 | protected virtual void Update() 109 | { 110 | Start(false); 111 | } 112 | 113 | #region Status 114 | 115 | public void AddStatusMessage(string statusMessage) 116 | { 117 | AddStatusMessage(new StatusMessage() 118 | { 119 | time = DateTime.Now, 120 | message = statusMessage 121 | }); 122 | } 123 | 124 | public void AddStatusMessage(StatusMessage statusMessage) 125 | { 126 | this.StatusMessages.Insert(0, statusMessage); 127 | TrimStatusMessages(); 128 | } 129 | 130 | protected void TrimStatusMessages() 131 | { 132 | int count = this.StatusMessages.Count; 133 | 134 | while (count > this.statusMessagesCount) 135 | { 136 | this.StatusMessages.RemoveAt(count - 1); 137 | 138 | count = count - 1; 139 | } 140 | } 141 | 142 | public void ClearStatusMessages() 143 | { 144 | this.StatusMessages.Clear(); 145 | } 146 | 147 | #endregion Status 148 | 149 | #region Start / Stop 150 | 151 | public virtual void Start(bool ignoreInterval = false) 152 | { 153 | if (!this.autoStart || this.NetworkType != UNetType.None) 154 | { 155 | this.previousAutoStartTimeSec = Time.timeSinceLevelLoad; 156 | return; 157 | } 158 | 159 | if (!ignoreInterval) 160 | { 161 | float elapsedTime = Time.timeSinceLevelLoad - this.previousAutoStartTimeSec; 162 | 163 | if (this.autoStartIntervalTimeSec > elapsedTime) 164 | { 165 | return; 166 | } 167 | } 168 | 169 | this.previousAutoStartTimeSec = Time.timeSinceLevelLoad; 170 | 171 | AddStatusMessage("Auto start as " + this.autoStartType.ToString() + "."); 172 | 173 | switch (this.autoStartType) 174 | { 175 | case UNetType.Server: { base.StartServer(); break; } 176 | case UNetType.Host: { base.StartHost(); break; } 177 | case UNetType.Client: { base.StartClient(); break; } 178 | } 179 | } 180 | 181 | public virtual void StartServerSafe() 182 | { 183 | if (this.NetworkType != UNetType.None) 184 | { 185 | AddStatusMessage("Faild to start server."); 186 | return; 187 | } 188 | 189 | base.StartServer(); 190 | } 191 | 192 | public virtual void StartHostSafe() 193 | { 194 | if (this.NetworkType != UNetType.None) 195 | { 196 | AddStatusMessage("Faild to start host."); 197 | return; 198 | } 199 | 200 | base.StartHost(); 201 | } 202 | 203 | public virtual void StartClientSafe() 204 | { 205 | if (this.NetworkType != UNetType.None) 206 | { 207 | AddStatusMessage("Faild to start client."); 208 | return; 209 | } 210 | 211 | base.StartClient(); 212 | } 213 | 214 | public virtual void Stop() 215 | { 216 | switch (this.NetworkType) 217 | { 218 | case UNetType.Server: { base.StopServer(); break; } 219 | case UNetType.Host: { base.StopHost(); break; } 220 | case UNetType.Client: { base.StopClient(); break; } 221 | case UNetType.None: 222 | { 223 | AddStatusMessage("Failed to Stop : Nothing is Started."); 224 | break; 225 | } 226 | } 227 | } 228 | 229 | #endregion Start / Stop 230 | 231 | #region EventHandler 232 | 233 | // NOTE: 234 | // When start as Host, OnStartServer() and OnStartClient() 235 | // are also called after OnStartHost() called. 236 | 237 | public override void OnStartServer() 238 | { 239 | if (this.NetworkType != UNetType.Host) 240 | { 241 | AddStatusMessage("Server start."); 242 | this.NetworkType = UNetType.Server; 243 | } 244 | 245 | base.OnStartServer(); 246 | 247 | this.startServerEvent.Invoke(); 248 | } 249 | 250 | public override void OnStopServer() 251 | { 252 | AddStatusMessage("Server stop."); 253 | 254 | this.NetworkType = UNetType.None; 255 | 256 | base.OnStopServer(); 257 | 258 | this.stopServerEvent.Invoke(); 259 | } 260 | 261 | public override void OnServerConnect(NetworkConnection networkConnection) 262 | { 263 | AddStatusMessage("Client connected. : " + networkConnection.address); 264 | 265 | base.OnServerConnect(networkConnection); 266 | 267 | this.serverConnectEvent.Invoke(networkConnection); 268 | } 269 | 270 | public override void OnServerDisconnect(NetworkConnection networkConnection) 271 | { 272 | AddStatusMessage("Client disconnected. : " + networkConnection.address); 273 | 274 | base.OnServerDisconnect(networkConnection); 275 | 276 | this.serverDisconnectEvent.Invoke(networkConnection); 277 | } 278 | 279 | public override void OnServerError(NetworkConnection networkConnection, int errorCode) 280 | { 281 | AddStatusMessage("Server error. : " + (NetworkError)errorCode); 282 | 283 | base.OnServerError(networkConnection, errorCode); 284 | 285 | this.serverErrorEvent.Invoke(networkConnection); 286 | } 287 | 288 | public override void OnStartHost() 289 | { 290 | AddStatusMessage("Host start."); 291 | 292 | this.NetworkType = UNetType.Host; 293 | 294 | base.OnStartHost(); 295 | 296 | this.startHostEvent.Invoke(); 297 | } 298 | 299 | public override void OnStopHost() 300 | { 301 | AddStatusMessage("Host stop."); 302 | 303 | this.NetworkType = UNetType.None; 304 | 305 | base.OnStopHost(); 306 | 307 | this.stopHostEvent.Invoke(); 308 | } 309 | 310 | public override void OnStartClient(NetworkClient networkClient) 311 | { 312 | if (this.NetworkType != UNetType.Host) 313 | { 314 | AddStatusMessage("Client start."); 315 | this.NetworkType = UNetType.Client; 316 | } 317 | 318 | base.OnStartClient(networkClient); 319 | 320 | this.startClientEvent.Invoke(); 321 | } 322 | 323 | public override void OnStopClient() 324 | { 325 | AddStatusMessage("Client stop."); 326 | 327 | this.NetworkType = UNetType.None; 328 | 329 | base.OnStopClient(); 330 | 331 | this.stopClientEvent.Invoke(); 332 | } 333 | 334 | public override void OnClientConnect(NetworkConnection networkConnection) 335 | { 336 | AddStatusMessage("Connected to server. : " + networkConnection.address); 337 | 338 | this.IsConnectedClient = true; 339 | 340 | base.OnClientConnect(networkConnection); 341 | 342 | this.clientConnectEvent.Invoke(networkConnection); 343 | } 344 | 345 | public override void OnClientDisconnect(NetworkConnection networkConnection) 346 | { 347 | if (this.IsConnectedClient) 348 | { 349 | AddStatusMessage("Disconnected from server. : " + networkConnection.address); 350 | } 351 | else 352 | { 353 | AddStatusMessage("Faild to connect server. : " + networkConnection.address); 354 | } 355 | 356 | this.IsConnectedClient = false; 357 | 358 | base.OnClientDisconnect(networkConnection); 359 | 360 | this.clientDisconnectEvent.Invoke(networkConnection); 361 | } 362 | 363 | public override void OnClientError(NetworkConnection networkConnection, int errorCode) 364 | { 365 | AddStatusMessage("Client error. : " + (NetworkError)errorCode); 366 | 367 | base.OnClientError(networkConnection, errorCode); 368 | 369 | this.clientErrorEvent.Invoke(networkConnection); 370 | } 371 | 372 | #endregion EventHandler 373 | 374 | #endregion Method 375 | } -------------------------------------------------------------------------------- /Assets/Packages/UNetworkManager/UNetworkManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b07d6c8c3669fd4cb0f00fdb4162a11 3 | timeCreated: 1486116773 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Packages/UNetworkManager/UNetworkManagerSettings.cs: -------------------------------------------------------------------------------- 1 | using static UNetworkManager; 2 | 3 | [System.Serializable] 4 | public class UNetworkManagerSettings 5 | { 6 | #region Field 7 | 8 | public string networkAddress; 9 | public int networkPort; 10 | public bool autoStart; 11 | public UNetType autoStartType; 12 | 13 | #endregion Field 14 | 15 | #region Method 16 | 17 | public void Save(UNetworkManager uNetworkManager) 18 | { 19 | this.networkAddress = uNetworkManager.networkAddress; 20 | this.networkPort = uNetworkManager.networkPort; 21 | this.autoStart = uNetworkManager.autoStart; 22 | this.autoStartType = uNetworkManager.autoStartType; 23 | } 24 | 25 | public void Load(UNetworkManager uNetworkManager) 26 | { 27 | bool active = uNetworkManager.isNetworkActive; 28 | 29 | if (active) 30 | { 31 | uNetworkManager.Stop(); 32 | uNetworkManager.ClearStatusMessages(); 33 | } 34 | 35 | uNetworkManager.networkAddress = this.networkAddress; 36 | uNetworkManager.networkPort = this.networkPort; 37 | uNetworkManager.autoStart = this.autoStart; 38 | uNetworkManager.autoStartType = this.autoStartType; 39 | 40 | // NOTE: 41 | // It couldn't restart network in the same frame. 42 | // Because of the port conflict. 43 | // 44 | //if (uNetworkManager.autoStart) 45 | //{ 46 | // uNetworkManager.Start(true); 47 | //} 48 | } 49 | 50 | #endregion Method 51 | } -------------------------------------------------------------------------------- /Assets/Packages/UNetworkManager/UNetworkManagerSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6fc6b1b1fab606f479b79ddb8afb35ae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SendReceiveMessageSample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Networking; 3 | 4 | public class SendReceiveMessageSample : NetworkBehaviour 5 | { 6 | #region Class 7 | 8 | public class SampleMessageType 9 | { 10 | public const short SampleMessage = MsgType.Highest + 1; 11 | } 12 | 13 | public class SampleMessage : MessageBase 14 | { 15 | public int value; 16 | } 17 | 18 | #endregion Class 19 | 20 | #region Field 21 | 22 | public int value; 23 | 24 | #endregion Field 25 | 26 | #region Method 27 | 28 | void Awake() 29 | { 30 | UNetworkManager.singleton.startClientEvent.AddListener(() => 31 | { 32 | UNetworkManager.singleton.client.RegisterHandler 33 | (SampleMessageType.SampleMessage, ReceiveMessage); 34 | }); 35 | } 36 | 37 | [ServerCallback] 38 | void Update() 39 | { 40 | if (Input.GetKeyDown(KeyCode.Return)) 41 | { 42 | this.value += 1; 43 | SendMessage(); 44 | } 45 | } 46 | 47 | void OnGUI() 48 | { 49 | GUILayout.Label("VALUE : " + value); 50 | } 51 | 52 | protected void ReceiveMessage(NetworkMessage networkMessage) 53 | { 54 | SampleMessage message = networkMessage.ReadMessage(); 55 | 56 | this.value = message.value; 57 | 58 | Debug.Log("RECEIVE : " + message.value); 59 | } 60 | 61 | public void SendMessage() 62 | { 63 | SampleMessage message = new SampleMessage() 64 | { 65 | value = this.value 66 | }; 67 | 68 | NetworkServer.SendToAll(SampleMessageType.SampleMessage, message); 69 | } 70 | 71 | #endregion Method 72 | } -------------------------------------------------------------------------------- /Assets/SendReceiveMessageSample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 977652d51dfdd184e847bc7cebe90847 3 | timeCreated: 1509094761 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/SendReceiveMessageSample.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/Assets/SendReceiveMessageSample.unity -------------------------------------------------------------------------------- /Assets/SendReceiveMessageSample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3f7c25c350a5fb43808daca4d609fb9 3 | timeCreated: 1509094671 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/SyncListSample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.Networking; 3 | 4 | public class SyncListSample : NetworkBehaviour 5 | { 6 | public int value; 7 | 8 | SyncListInt syncList = new SyncListInt(); 9 | 10 | void Start() 11 | { 12 | this.syncList.Callback += OnChanged; 13 | this.syncList.Add(value); 14 | } 15 | 16 | void Update() 17 | { 18 | if (base.isServer) 19 | { 20 | if (Input.GetKeyDown(KeyCode.Return)) 21 | { 22 | // NOTE: 23 | // "this.value" will keep the value, 24 | // and "this.syncList[0]" will update. 25 | 26 | this.syncList[0] += 1; 27 | } 28 | } 29 | } 30 | 31 | private void OnGUI() 32 | { 33 | GUILayout.Label("value / syncList = " + this.value + " / " + this.syncList[0]); 34 | } 35 | 36 | private void OnChanged(SyncListInt.Operation op, int index) 37 | { 38 | Debug.Log("OnChanged : " + op + " : " + this.value + " / " + this.syncList[index]); 39 | } 40 | } -------------------------------------------------------------------------------- /Assets/SyncListSample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c2b3170bd2644f442a4253b79589ba0f 3 | timeCreated: 1512723213 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/SyncListSample.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/Assets/SyncListSample.unity -------------------------------------------------------------------------------- /Assets/SyncListSample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0aa5938c4d9a5574fb9970f6d6fe9e8e 3 | timeCreated: 1512723931 4 | licenseType: Pro 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/UNetworkManagerSample.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public class UNetworkManagerSample : MonoBehaviour 4 | { 5 | #region Field 6 | 7 | public string networkAddress = "127.0.0.1"; 8 | public int networkPort = 5555; 9 | 10 | #endregion Field 11 | 12 | #region Method 13 | 14 | protected virtual void Start() 15 | { 16 | UNetworkManager.singleton.networkAddress = this.networkAddress; 17 | UNetworkManager.singleton.networkPort = this.networkPort; 18 | } 19 | 20 | protected virtual void Update () 21 | { 22 | if (Input.GetKeyDown(KeyCode.A)) 23 | { 24 | UNetworkManager.singleton.autoStart = !UNetworkManager.singleton.autoStart; 25 | } 26 | 27 | if (Input.GetKeyDown(KeyCode.S)) 28 | { 29 | UNetworkManager.singleton.StartServerSafe(); 30 | } 31 | 32 | if (Input.GetKeyDown(KeyCode.H)) 33 | { 34 | UNetworkManager.singleton.StartHostSafe(); 35 | } 36 | 37 | if (Input.GetKeyDown(KeyCode.C)) 38 | { 39 | UNetworkManager.singleton.StartClientSafe(); 40 | } 41 | 42 | if (Input.GetKeyDown(KeyCode.D)) 43 | { 44 | UNetworkManager.singleton.Stop(); 45 | } 46 | } 47 | 48 | protected virtual void OnGUI() 49 | { 50 | GUILayout.Label("___Key Control___"); 51 | GUILayout.Label("[A] Toggle Auto Start : " + (UNetworkManager.singleton.autoStart ? "ON" : "OFF")); 52 | GUILayout.Label(UNetworkManager.singleton.AutoStartIntervalTick.ToString()); 53 | GUILayout.Label("[S] Start As Server"); 54 | GUILayout.Label("[H] Start As Host"); 55 | GUILayout.Label("[C] Start As Client"); 56 | GUILayout.Label("[D] Stop"); 57 | 58 | GUILayout.Label("___Status Log___"); 59 | 60 | //GUILayout.BeginArea(new Rect(100, 100, 300, 300)); 61 | 62 | foreach (UNetworkManager.StatusMessage statusMessage in UNetworkManager.singleton.StatusMessages) 63 | { 64 | GUILayout.Label(statusMessage.time.ToLongTimeString() + " - "+ statusMessage.message); 65 | } 66 | 67 | //GUILayout.EndArea(); 68 | } 69 | 70 | public virtual void SampleEventHandler() 71 | { 72 | UNetworkManager.singleton.AddStatusMessage("EventHandle Message."); 73 | } 74 | 75 | #endregion Method 76 | } -------------------------------------------------------------------------------- /Assets/UNetworkManagerSample.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e6f90a9ecb6a49d459be49c9daf73228 3 | timeCreated: 1486116895 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/UNetworkManagerSample.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/Assets/UNetworkManagerSample.unity -------------------------------------------------------------------------------- /Assets/UNetworkManagerSample.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f2a787d16e03c24cb9d19d0af7360b4 3 | timeCreated: 1486118847 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/csc.rsp: -------------------------------------------------------------------------------- 1 | -nowarn:0618 2 | -nowarn:0649 -------------------------------------------------------------------------------- /Assets/csc.rsp.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18dbbf9df583d794a887d9fbebd37189 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, XJINE 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Logs/Packages-Update.log: -------------------------------------------------------------------------------- 1 | 2 | === Mon Jan 6 16:35:32 2020 3 | 4 | Packages were changed. 5 | Update Mode: updateDependencies 6 | 7 | The following packages were added: 8 | com.unity.2d.tilemap@1.0.0 9 | com.unity.ext.nunit@1.0.0 10 | com.unity.test-framework@1.0.13 11 | com.unity.2d.sprite@1.0.0 12 | com.unity.ide.vscode@1.1.2 13 | com.unity.ide.rider@1.1.0 14 | com.unity.ugui@1.0.0 15 | com.unity.modules.androidjni@1.0.0 16 | The following packages were updated: 17 | com.unity.package-manager-ui from version 2.1.2 to 2.2.0 18 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.multiplayer-hlapi": "1.0.4", 4 | "com.unity.package-manager-ui": "2.2.0", 5 | "com.unity.modules.ai": "1.0.0", 6 | "com.unity.modules.androidjni": "1.0.0", 7 | "com.unity.modules.animation": "1.0.0", 8 | "com.unity.modules.assetbundle": "1.0.0", 9 | "com.unity.modules.audio": "1.0.0", 10 | "com.unity.modules.cloth": "1.0.0", 11 | "com.unity.modules.director": "1.0.0", 12 | "com.unity.modules.imageconversion": "1.0.0", 13 | "com.unity.modules.imgui": "1.0.0", 14 | "com.unity.modules.jsonserialize": "1.0.0", 15 | "com.unity.modules.particlesystem": "1.0.0", 16 | "com.unity.modules.physics": "1.0.0", 17 | "com.unity.modules.physics2d": "1.0.0", 18 | "com.unity.modules.screencapture": "1.0.0", 19 | "com.unity.modules.terrain": "1.0.0", 20 | "com.unity.modules.terrainphysics": "1.0.0", 21 | "com.unity.modules.tilemap": "1.0.0", 22 | "com.unity.modules.ui": "1.0.0", 23 | "com.unity.modules.uielements": "1.0.0", 24 | "com.unity.modules.umbra": "1.0.0", 25 | "com.unity.modules.unityanalytics": "1.0.0", 26 | "com.unity.modules.unitywebrequest": "1.0.0", 27 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 28 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 29 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 30 | "com.unity.modules.unitywebrequestwww": "1.0.0", 31 | "com.unity.modules.vehicles": "1.0.0", 32 | "com.unity.modules.video": "1.0.0", 33 | "com.unity.modules.vr": "1.0.0", 34 | "com.unity.modules.wind": "1.0.0", 35 | "com.unity.modules.xr": "1.0.0" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2019.2.14f1 2 | m_EditorVersionWithRevision: 2019.2.14f1 (49dd4e9fa428) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/ProjectSettings/VFXManager.asset -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity_UNetworkManager 2 | 3 | ![](https://github.com/XJINE/Unity_UNetworkManager/blob/master/screenshot.png) 4 | 5 | This is default "NetworkManager" extension. 6 | 7 | - Auto Connection. 8 | - When failed to connect or when disconnected, try again. 9 | - Event Logging. 10 | - Start 11 | - Connect 12 | - Disconnect 13 | - Lots of Event. 14 | 15 | And, this includes ``csc.rsp`` file to ignore UNET alert in UnityEditor. 16 | 17 | ## EventHandler 18 | 19 | | Name | Called when | Called In | 20 | | ---------------------------- | ------------------------ | ----------- | 21 | | StartServerEventHandler | Start as Server | Server side | 22 | | StopServerEventHandler | Stop Server | Server side | 23 | | ServerConnectEventHandler | Client connect | Server side | 24 | | ServerDisconnectEventHandler | Client disconnect | Server side | 25 | | ServerErrorEventHandler | Error occurred in Server | Server side | 26 | | StartHostEventHandler | Start as Host | Server side | 27 | | StopHostEventHandler | Stop Host | Server side | 28 | | StartClientEventHandler | Start as Client | Client side | 29 | | StopClientEventHandler | Stop Client | Client side | 30 | | ClientConnectEventHandler | Connect to Server | Client side | 31 | | ClientDiscconectEventHandler | Disconnect from Server | Client side | 32 | | ClientErrorEventHandler | Error occurred in Client | Client side | 33 | 34 | ## Import to Your Project 35 | 36 | You can import this asset from UnityPackage. 37 | 38 | - [UNetworkManager.unitypackage](https://github.com/XJINE/Unity_UNetworkManager/blob/master/UNetworkManager.unitypackage) -------------------------------------------------------------------------------- /UNetworkManager.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/UNetworkManager.unitypackage -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XJINE/Unity_UNetworkManager/7dedb05fec2f720c1a5ad92ba9cc5e6ff10f6777/screenshot.png --------------------------------------------------------------------------------