Mirror override fix
This commit is contained in:
parent
a329f8fd44
commit
0067b50d3f
565 changed files with 1905 additions and 3344 deletions
|
|
@ -3,6 +3,6 @@ guid: 1b2f9d254154cd942ba40b06b869b8f3
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@ namespace Mirror.Authenticators
|
||||||
public string username;
|
public string username;
|
||||||
public string password;
|
public string password;
|
||||||
|
|
||||||
|
// this is set if authentication fails to prevent garbage AuthRequestMessage spam
|
||||||
|
bool ServerAuthFailed;
|
||||||
|
|
||||||
#region Messages
|
#region Messages
|
||||||
|
|
||||||
public struct AuthRequestMessage : NetworkMessage
|
public struct AuthRequestMessage : NetworkMessage
|
||||||
|
|
@ -101,9 +104,15 @@ namespace Mirror.Authenticators
|
||||||
conn.isAuthenticated = false;
|
conn.isAuthenticated = false;
|
||||||
|
|
||||||
// disconnect the client after 1 second so that response message gets delivered
|
// disconnect the client after 1 second so that response message gets delivered
|
||||||
|
if (!ServerAuthFailed)
|
||||||
|
{
|
||||||
|
// set this false so this coroutine can only be started once
|
||||||
|
ServerAuthFailed = true;
|
||||||
|
|
||||||
StartCoroutine(DelayedDisconnect(conn, 1));
|
StartCoroutine(DelayedDisconnect(conn, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerator DelayedDisconnect(NetworkConnection conn, float waitTime)
|
IEnumerator DelayedDisconnect(NetworkConnection conn, float waitTime)
|
||||||
{
|
{
|
||||||
|
|
@ -141,7 +150,7 @@ namespace Mirror.Authenticators
|
||||||
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
|
/// Called on client from OnClientAuthenticateInternal when a client needs to authenticate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="conn">Connection of the client.</param>
|
/// <param name="conn">Connection of the client.</param>
|
||||||
public override void OnClientAuthenticate(NetworkConnection conn)
|
public override void OnClientAuthenticate()
|
||||||
{
|
{
|
||||||
AuthRequestMessage authRequestMessage = new AuthRequestMessage
|
AuthRequestMessage authRequestMessage = new AuthRequestMessage
|
||||||
{
|
{
|
||||||
|
|
@ -149,13 +158,15 @@ namespace Mirror.Authenticators
|
||||||
authPassword = password
|
authPassword = password
|
||||||
};
|
};
|
||||||
|
|
||||||
conn.Send(authRequestMessage);
|
NetworkClient.connection.Send(authRequestMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
|
||||||
|
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called on client when the server's AuthResponseMessage arrives
|
/// Called on client when the server's AuthResponseMessage arrives
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="conn">Connection to client.</param>
|
|
||||||
/// <param name="msg">The message payload</param>
|
/// <param name="msg">The message payload</param>
|
||||||
public void OnAuthResponseMessage(AuthResponseMessage msg)
|
public void OnAuthResponseMessage(AuthResponseMessage msg)
|
||||||
{
|
{
|
||||||
|
|
@ -164,20 +175,17 @@ namespace Mirror.Authenticators
|
||||||
// Debug.LogFormat(LogType.Log, "Authentication Response: {0}", msg.message);
|
// Debug.LogFormat(LogType.Log, "Authentication Response: {0}", msg.message);
|
||||||
|
|
||||||
// Authentication has been accepted
|
// Authentication has been accepted
|
||||||
ClientAccept(NetworkClient.connection);
|
ClientAccept();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError($"Authentication Response: {msg.message}");
|
Debug.LogError($"Authentication Response: {msg.message}");
|
||||||
|
|
||||||
// Authentication has been rejected
|
// Authentication has been rejected
|
||||||
ClientReject(NetworkClient.connection);
|
ClientReject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete("Call OnAuthResponseMessage without the NetworkConnection parameter. It always points to NetworkClient.connection anyway.")]
|
|
||||||
public void OnAuthResponseMessage(NetworkConnection conn, AuthResponseMessage msg) => OnAuthResponseMessage(msg);
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ fileFormatVersion: 2
|
||||||
guid: e720aa64e3f58fb4880566a322584340
|
guid: e720aa64e3f58fb4880566a322584340
|
||||||
AssemblyDefinitionImporter:
|
AssemblyDefinitionImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -48,23 +48,21 @@ namespace Mirror.Authenticators
|
||||||
StartCoroutine(BeginAuthentication(conn));
|
StartCoroutine(BeginAuthentication(conn));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnClientAuthenticate(NetworkConnection conn)
|
public override void OnClientAuthenticate()
|
||||||
{
|
{
|
||||||
authenticator.OnClientAuthenticate(conn);
|
authenticator.OnClientAuthenticate();
|
||||||
if (timeout > 0)
|
if (timeout > 0)
|
||||||
StartCoroutine(BeginAuthentication(conn));
|
StartCoroutine(BeginAuthentication(NetworkClient.connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator BeginAuthentication(NetworkConnection conn)
|
IEnumerator BeginAuthentication(NetworkConnection conn)
|
||||||
{
|
{
|
||||||
// Debug.Log($"Authentication countdown started {conn} {timeout}");
|
// Debug.Log($"Authentication countdown started {conn} {timeout}");
|
||||||
|
|
||||||
yield return new WaitForSecondsRealtime(timeout);
|
yield return new WaitForSecondsRealtime(timeout);
|
||||||
|
|
||||||
if (!conn.isAuthenticated)
|
if (!conn.isAuthenticated)
|
||||||
{
|
{
|
||||||
// Debug.Log($"Authentication Timeout {conn}");
|
// Debug.Log($"Authentication Timeout {conn}");
|
||||||
|
|
||||||
conn.Disconnect();
|
conn.Disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: 73a9bb2dacafa8141bce8feef34e33a7
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,61 +1 @@
|
||||||
using Mirror.Cloud.ListServerService;
|
// removed 2021-05-13
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Used to requests and responses from the mirror api
|
|
||||||
/// </summary>
|
|
||||||
public interface IApiConnector
|
|
||||||
{
|
|
||||||
ListServer ListServer { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to requests and responses from the mirror api
|
|
||||||
/// </summary>
|
|
||||||
[DisallowMultipleComponent]
|
|
||||||
[AddComponentMenu("Network/CloudServices/ApiConnector")]
|
|
||||||
[HelpURL("https://mirror-networking.com/docs/api/Mirror.Cloud.ApiConnector.html")]
|
|
||||||
public class ApiConnector : MonoBehaviour, IApiConnector, ICoroutineRunner
|
|
||||||
{
|
|
||||||
#region Inspector
|
|
||||||
[Header("Settings")]
|
|
||||||
|
|
||||||
[Tooltip("Base URL of api, including https")]
|
|
||||||
[SerializeField] string ApiAddress = "";
|
|
||||||
|
|
||||||
[Tooltip("Api key required to access api")]
|
|
||||||
[SerializeField] string ApiKey = "";
|
|
||||||
|
|
||||||
[Header("Events")]
|
|
||||||
|
|
||||||
[Tooltip("Triggered when server list updates")]
|
|
||||||
[SerializeField] ServerListEvent _onServerListUpdated = new ServerListEvent();
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
IRequestCreator requestCreator;
|
|
||||||
|
|
||||||
public ListServer ListServer { get; private set; }
|
|
||||||
|
|
||||||
void Awake()
|
|
||||||
{
|
|
||||||
requestCreator = new RequestCreator(ApiAddress, ApiKey, this);
|
|
||||||
|
|
||||||
InitListServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitListServer()
|
|
||||||
{
|
|
||||||
IListServerServerApi serverApi = new ListServerServerApi(this, requestCreator);
|
|
||||||
IListServerClientApi clientApi = new ListServerClientApi(this, requestCreator, _onServerListUpdated);
|
|
||||||
ListServer = new ListServer(serverApi, clientApi);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnDestroy()
|
|
||||||
{
|
|
||||||
ListServer?.ServerApi.Shutdown();
|
|
||||||
ListServer?.ClientApi.Shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
public interface IBaseApi
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Cleans up any data created by the instance
|
|
||||||
/// <para>For Example: removing server from list</para>
|
|
||||||
/// </summary>
|
|
||||||
void Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract class BaseApi
|
|
||||||
{
|
|
||||||
protected readonly ICoroutineRunner runner;
|
|
||||||
protected readonly IRequestCreator requestCreator;
|
|
||||||
|
|
||||||
protected BaseApi(ICoroutineRunner runner, IRequestCreator requestCreator)
|
|
||||||
{
|
|
||||||
this.runner = runner ?? throw new ArgumentNullException(nameof(runner));
|
|
||||||
this.requestCreator = requestCreator ?? throw new ArgumentNullException(nameof(requestCreator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
using Mirror.Cloud.ListServerService;
|
|
||||||
using UnityEngine.Events;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public class ServerListEvent : UnityEvent<ServerCollectionJson> {}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public class MatchFoundEvent : UnityEvent<ServerJson> {}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1 @@
|
||||||
using UnityEngine.Networking;
|
// removed 2021-05-13
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
public static class Extensions
|
|
||||||
{
|
|
||||||
public static bool IsOk(this UnityWebRequest webRequest)
|
|
||||||
{
|
|
||||||
return 200 <= webRequest.responseCode && webRequest.responseCode <= 299;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1 @@
|
||||||
using System.Collections;
|
// removed 2021-05-13
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
public interface ICoroutineRunner : IUnityEqualCheck
|
|
||||||
{
|
|
||||||
Coroutine StartCoroutine(IEnumerator routine);
|
|
||||||
void StopCoroutine(IEnumerator routine);
|
|
||||||
void StopCoroutine(Coroutine routine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1 @@
|
||||||
using System.Collections;
|
// removed 2021-05-13
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
public delegate void RequestSuccess(string responseBody);
|
|
||||||
|
|
||||||
public delegate void RequestFail(string responseBody);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Objects that can be sent to the Api must have this interface
|
|
||||||
/// </summary>
|
|
||||||
public interface ICanBeJson {}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Methods to create and send UnityWebRequest
|
|
||||||
/// </summary>
|
|
||||||
public interface IRequestCreator
|
|
||||||
{
|
|
||||||
UnityWebRequest Delete(string page);
|
|
||||||
UnityWebRequest Get(string page);
|
|
||||||
UnityWebRequest Patch<T>(string page, T json) where T : struct, ICanBeJson;
|
|
||||||
UnityWebRequest Post<T>(string page, T json) where T : struct, ICanBeJson;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sends Request to api and invokes callback when finished
|
|
||||||
/// <para>Starts Coroutine of SendRequestEnumerator</para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="onSuccess"></param>
|
|
||||||
/// <param name="onFail"></param>
|
|
||||||
void SendRequest(UnityWebRequest request, RequestSuccess onSuccess = null, RequestFail onFail = null);
|
|
||||||
/// <summary>
|
|
||||||
/// Sends Request to api and invokes callback when finished
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="request"></param>
|
|
||||||
/// <param name="onSuccess"></param>
|
|
||||||
/// <param name="onFail"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
IEnumerator SendRequestEnumerator(UnityWebRequest request, RequestSuccess onSuccess = null, RequestFail onFail = null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1 @@
|
||||||
using UnityEngine;
|
// removed 2021-05-13
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Adds Extension to check if unity object is null.
|
|
||||||
/// <para>Use these methods to stop MissingReferenceException</para>
|
|
||||||
/// </summary>
|
|
||||||
public interface IUnityEqualCheck
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class UnityEqualCheckExtension
|
|
||||||
{
|
|
||||||
public static bool IsNull(this IUnityEqualCheck obj)
|
|
||||||
{
|
|
||||||
return (obj as Object) == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsNotNull(this IUnityEqualCheck obj)
|
|
||||||
{
|
|
||||||
return (obj as Object) != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public struct CreatedIdJson : ICanBeJson
|
|
||||||
{
|
|
||||||
public string id;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public struct ErrorJson : ICanBeJson
|
|
||||||
{
|
|
||||||
public string code;
|
|
||||||
public string message;
|
|
||||||
|
|
||||||
public int HtmlCode => int.Parse(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public struct EmptyJson : ICanBeJson
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,62 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
public static class Logger
|
|
||||||
{
|
|
||||||
public static bool VerboseLogging = false;
|
|
||||||
|
|
||||||
public static void LogRequest(string page, string method, bool hasJson, string json)
|
|
||||||
{
|
|
||||||
if (hasJson)
|
|
||||||
{
|
|
||||||
Debug.LogFormat("Request: {0} {1} {2}", method, page, json);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogFormat("Request: {0} {1}", method, page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void LogResponse(UnityWebRequest statusRequest)
|
|
||||||
{
|
|
||||||
long code = statusRequest.responseCode;
|
|
||||||
|
|
||||||
string format = "Response: {0} {1} {2} {3}";
|
|
||||||
// we split path like this to make sure api key doesn't leak
|
|
||||||
Uri uri = new Uri(statusRequest.url);
|
|
||||||
string path = string.Join("", uri.Segments);
|
|
||||||
string msg = string.Format(format, statusRequest.method, code, path, statusRequest.downloadHandler.text);
|
|
||||||
Debug.Log(msg);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(statusRequest.error))
|
|
||||||
{
|
|
||||||
msg = string.Format("WEB REQUEST ERROR: {0}", statusRequest.error);
|
|
||||||
Debug.LogError(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void Log(string msg)
|
|
||||||
{
|
|
||||||
Debug.Log(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void LogWarning(string msg)
|
|
||||||
{
|
|
||||||
Debug.LogWarning(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void LogError(string msg)
|
|
||||||
{
|
|
||||||
Debug.LogError(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void Verbose(string msg)
|
|
||||||
{
|
|
||||||
if (VerboseLogging)
|
|
||||||
Debug.Log(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,144 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
using System.Collections;
|
|
||||||
using System.Text;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Methods to create and send UnityWebRequest
|
|
||||||
/// </summary>
|
|
||||||
public class RequestCreator : IRequestCreator
|
|
||||||
{
|
|
||||||
const string GET = "GET";
|
|
||||||
const string POST = "POST";
|
|
||||||
const string PATCH = "PATCH";
|
|
||||||
const string DELETE = "DELETE";
|
|
||||||
|
|
||||||
public readonly string baseAddress;
|
|
||||||
public readonly string apiKey;
|
|
||||||
readonly ICoroutineRunner runner;
|
|
||||||
|
|
||||||
public RequestCreator(string baseAddress, string apiKey, ICoroutineRunner coroutineRunner)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(baseAddress))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(baseAddress));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(apiKey))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(apiKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.baseAddress = baseAddress;
|
|
||||||
this.apiKey = apiKey;
|
|
||||||
|
|
||||||
runner = coroutineRunner ?? throw new ArgumentNullException(nameof(coroutineRunner));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Uri CreateUri(string page)
|
|
||||||
{
|
|
||||||
return new Uri(string.Format("{0}/{1}?key={2}", baseAddress, page, apiKey));
|
|
||||||
}
|
|
||||||
|
|
||||||
UnityWebRequest CreateWebRequest(string page, string method, string json = null)
|
|
||||||
{
|
|
||||||
bool hasJson = !string.IsNullOrEmpty(json);
|
|
||||||
Logger.LogRequest(page, method, hasJson, json);
|
|
||||||
|
|
||||||
UnityWebRequest request = new UnityWebRequest(CreateUri(page));
|
|
||||||
request.method = method;
|
|
||||||
if (hasJson)
|
|
||||||
{
|
|
||||||
request.SetRequestHeader("Content-Type", "application/json");
|
|
||||||
}
|
|
||||||
|
|
||||||
request.downloadHandler = new DownloadHandlerBuffer();
|
|
||||||
|
|
||||||
byte[] bodyRaw = hasJson
|
|
||||||
? Encoding.UTF8.GetBytes(json)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
|
||||||
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create Get Request to page
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public UnityWebRequest Get(string page)
|
|
||||||
{
|
|
||||||
return CreateWebRequest(page, GET);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates Post Request to page with Json body
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <param name="json"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public UnityWebRequest Post<T>(string page, T json) where T : struct, ICanBeJson
|
|
||||||
{
|
|
||||||
string jsonString = JsonUtility.ToJson(json);
|
|
||||||
return CreateWebRequest(page, POST, jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates Patch Request to page with Json body
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <param name="json"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public UnityWebRequest Patch<T>(string page, T json) where T : struct, ICanBeJson
|
|
||||||
{
|
|
||||||
string jsonString = JsonUtility.ToJson(json);
|
|
||||||
return CreateWebRequest(page, PATCH, jsonString);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create Delete Request to page
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public UnityWebRequest Delete(string page)
|
|
||||||
{
|
|
||||||
return CreateWebRequest(page, DELETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void SendRequest(UnityWebRequest request, RequestSuccess onSuccess = null, RequestFail onFail = null)
|
|
||||||
{
|
|
||||||
runner.StartCoroutine(SendRequestEnumerator(request, onSuccess, onFail));
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator SendRequestEnumerator(UnityWebRequest request, RequestSuccess onSuccess = null, RequestFail onFail = null)
|
|
||||||
{
|
|
||||||
using (UnityWebRequest webRequest = request)
|
|
||||||
{
|
|
||||||
yield return webRequest.SendWebRequest();
|
|
||||||
Logger.LogResponse(webRequest);
|
|
||||||
|
|
||||||
string text = webRequest.downloadHandler.text;
|
|
||||||
Logger.Verbose(text);
|
|
||||||
if (webRequest.IsOk())
|
|
||||||
{
|
|
||||||
onSuccess?.Invoke(text);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
onFail?.Invoke(text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,66 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
using UnityEngine.Events;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud.ListServerService
|
|
||||||
{
|
|
||||||
public sealed class ListServer
|
|
||||||
{
|
|
||||||
public readonly IListServerServerApi ServerApi;
|
|
||||||
public readonly IListServerClientApi ClientApi;
|
|
||||||
|
|
||||||
public ListServer(IListServerServerApi serverApi, IListServerClientApi clientApi)
|
|
||||||
{
|
|
||||||
ServerApi = serverApi ?? throw new ArgumentNullException(nameof(serverApi));
|
|
||||||
ClientApi = clientApi ?? throw new ArgumentNullException(nameof(clientApi));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IListServerServerApi : IBaseApi
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Has a server been added to the list with this connection
|
|
||||||
/// </summary>
|
|
||||||
bool ServerInList { get; }
|
|
||||||
/// <summary>
|
|
||||||
/// Add a server to the list
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="server"></param>
|
|
||||||
void AddServer(ServerJson server);
|
|
||||||
/// <summary>
|
|
||||||
/// Update the current server
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="newPlayerCount"></param>
|
|
||||||
void UpdateServer(int newPlayerCount);
|
|
||||||
/// <summary>
|
|
||||||
/// Update the current server
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="server"></param>
|
|
||||||
void UpdateServer(ServerJson server);
|
|
||||||
/// <summary>
|
|
||||||
/// Removes the current server
|
|
||||||
/// </summary>
|
|
||||||
void RemoveServer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IListServerClientApi : IBaseApi
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Called when the server list is updated
|
|
||||||
/// </summary>
|
|
||||||
event UnityAction<ServerCollectionJson> onServerListUpdated;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the server list once
|
|
||||||
/// </summary>
|
|
||||||
void GetServerList();
|
|
||||||
/// <summary>
|
|
||||||
/// Start getting the server list every interval
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="interval"></param>
|
|
||||||
void StartGetServerListRepeat(int interval);
|
|
||||||
/// <summary>
|
|
||||||
/// Stop getting the server list
|
|
||||||
/// </summary>
|
|
||||||
void StopGetServerListRepeat();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1 @@
|
||||||
namespace Mirror.Cloud.ListServerService
|
// removed 2021-05-13
|
||||||
{
|
|
||||||
public abstract class ListServerBaseApi : BaseApi
|
|
||||||
{
|
|
||||||
protected ListServerBaseApi(ICoroutineRunner runner, IRequestCreator requestCreator) : base(runner, requestCreator)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,70 +1 @@
|
||||||
using System.Collections;
|
// removed 2021-05-13
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Events;
|
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud.ListServerService
|
|
||||||
{
|
|
||||||
public sealed class ListServerClientApi : ListServerBaseApi, IListServerClientApi
|
|
||||||
{
|
|
||||||
readonly ServerListEvent _onServerListUpdated;
|
|
||||||
|
|
||||||
Coroutine getServerListRepeatCoroutine;
|
|
||||||
|
|
||||||
public event UnityAction<ServerCollectionJson> onServerListUpdated
|
|
||||||
{
|
|
||||||
add => _onServerListUpdated.AddListener(value);
|
|
||||||
remove => _onServerListUpdated.RemoveListener(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ListServerClientApi(ICoroutineRunner runner, IRequestCreator requestCreator, ServerListEvent onServerListUpdated) : base(runner, requestCreator)
|
|
||||||
{
|
|
||||||
_onServerListUpdated = onServerListUpdated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Shutdown()
|
|
||||||
{
|
|
||||||
StopGetServerListRepeat();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetServerList()
|
|
||||||
{
|
|
||||||
runner.StartCoroutine(getServerList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartGetServerListRepeat(int interval)
|
|
||||||
{
|
|
||||||
getServerListRepeatCoroutine = runner.StartCoroutine(GetServerListRepeat(interval));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StopGetServerListRepeat()
|
|
||||||
{
|
|
||||||
// if runner is null it has been destroyed and will already be null
|
|
||||||
if (runner.IsNotNull() && getServerListRepeatCoroutine != null)
|
|
||||||
{
|
|
||||||
runner.StopCoroutine(getServerListRepeatCoroutine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator GetServerListRepeat(int interval)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
yield return getServerList();
|
|
||||||
|
|
||||||
yield return new WaitForSeconds(interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IEnumerator getServerList()
|
|
||||||
{
|
|
||||||
UnityWebRequest request = requestCreator.Get("servers");
|
|
||||||
yield return requestCreator.SendRequestEnumerator(request, onSuccess);
|
|
||||||
|
|
||||||
void onSuccess(string responseBody)
|
|
||||||
{
|
|
||||||
ServerCollectionJson serverlist = JsonUtility.FromJson<ServerCollectionJson>(responseBody);
|
|
||||||
_onServerListUpdated?.Invoke(serverlist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,207 +1 @@
|
||||||
using System;
|
// removed 2021-05-13
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud.ListServerService
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public struct ServerCollectionJson : ICanBeJson
|
|
||||||
{
|
|
||||||
public ServerJson[] servers;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public struct ServerJson : ICanBeJson
|
|
||||||
{
|
|
||||||
public string protocol;
|
|
||||||
public int port;
|
|
||||||
public int playerCount;
|
|
||||||
public int maxPlayerCount;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// optional
|
|
||||||
/// </summary>
|
|
||||||
public string displayName;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Uri string of the ip and port of the server.
|
|
||||||
/// <para>The ip is calculated by the request to the API</para>
|
|
||||||
/// <para>This is returns from the api, any incoming address fields will be ignored</para>
|
|
||||||
/// </summary>
|
|
||||||
public string address;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Can be used to set custom uri
|
|
||||||
/// <para>optional</para>
|
|
||||||
/// </summary>
|
|
||||||
public string customAddress;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Array of custom data, use SetCustomData to set values
|
|
||||||
/// <para>optional</para>
|
|
||||||
/// </summary>
|
|
||||||
public KeyValue[] customData;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Uri from address field
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Uri GetServerUri() => new Uri(address);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Uri from customAddress field
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public Uri GetCustomUri() => new Uri(customAddress);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the customData array
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="data"></param>
|
|
||||||
public void SetCustomData(Dictionary<string, string> data)
|
|
||||||
{
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
customData = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
customData = data.ToKeyValueArray();
|
|
||||||
CustomDataHelper.ValidateCustomData(customData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Validate()
|
|
||||||
{
|
|
||||||
CustomDataHelper.ValidateCustomData(customData);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(protocol))
|
|
||||||
{
|
|
||||||
Logger.LogError("ServerJson should not have empty protocol");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (port == 0)
|
|
||||||
{
|
|
||||||
Logger.LogError("ServerJson should not have port equal 0");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxPlayerCount == 0)
|
|
||||||
{
|
|
||||||
Logger.LogError("ServerJson should not have maxPlayerCount equal 0");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public struct PartialServerJson : ICanBeJson
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// optional
|
|
||||||
/// </summary>
|
|
||||||
public int playerCount;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// optional
|
|
||||||
/// </summary>
|
|
||||||
public int maxPlayerCount;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// optional
|
|
||||||
/// </summary>
|
|
||||||
public string displayName;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Array of custom data, use SetCustomData to set values
|
|
||||||
/// <para>optional</para>
|
|
||||||
/// </summary>
|
|
||||||
public KeyValue[] customData;
|
|
||||||
|
|
||||||
|
|
||||||
public void SetCustomData(Dictionary<string, string> data)
|
|
||||||
{
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
customData = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
customData = data.ToKeyValueArray();
|
|
||||||
CustomDataHelper.ValidateCustomData(customData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Validate()
|
|
||||||
{
|
|
||||||
CustomDataHelper.ValidateCustomData(customData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CustomDataHelper
|
|
||||||
{
|
|
||||||
const int MaxCustomData = 16;
|
|
||||||
|
|
||||||
public static Dictionary<string, string> ToDictionary(this KeyValue[] keyValues)
|
|
||||||
{
|
|
||||||
return keyValues.ToDictionary(x => x.key, x => x.value);
|
|
||||||
}
|
|
||||||
public static KeyValue[] ToKeyValueArray(this Dictionary<string, string> dictionary)
|
|
||||||
{
|
|
||||||
return dictionary.Select(kvp => new KeyValue(kvp.Key, kvp.Value)).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ValidateCustomData(KeyValue[] customData)
|
|
||||||
{
|
|
||||||
if (customData == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customData.Length > MaxCustomData)
|
|
||||||
{
|
|
||||||
Logger.LogError($"There can only be {MaxCustomData} custom data but there was {customData.Length} values given");
|
|
||||||
Array.Resize(ref customData, MaxCustomData);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (KeyValue item in customData)
|
|
||||||
{
|
|
||||||
item.Validate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
public struct KeyValue
|
|
||||||
{
|
|
||||||
const int MaxKeySize = 32;
|
|
||||||
const int MaxValueSize = 256;
|
|
||||||
|
|
||||||
public string key;
|
|
||||||
public string value;
|
|
||||||
|
|
||||||
public KeyValue(string key, string value)
|
|
||||||
{
|
|
||||||
this.key = key;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Validate()
|
|
||||||
{
|
|
||||||
if (key.Length > MaxKeySize)
|
|
||||||
{
|
|
||||||
Logger.LogError($"Custom Data must have key with length less than {MaxKeySize}");
|
|
||||||
key = key.Substring(0, MaxKeySize);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value.Length > MaxValueSize)
|
|
||||||
{
|
|
||||||
Logger.LogError($"Custom Data must have value with length less than {MaxValueSize}");
|
|
||||||
value = value.Substring(0, MaxValueSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,219 +1 @@
|
||||||
using System.Collections;
|
// removed 2021-05-13
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Networking;
|
|
||||||
|
|
||||||
namespace Mirror.Cloud.ListServerService
|
|
||||||
{
|
|
||||||
public sealed class ListServerServerApi : ListServerBaseApi, IListServerServerApi
|
|
||||||
{
|
|
||||||
const int PingInterval = 20;
|
|
||||||
const int MaxPingFails = 15;
|
|
||||||
|
|
||||||
ServerJson currentServer;
|
|
||||||
string serverId;
|
|
||||||
|
|
||||||
Coroutine _pingCoroutine;
|
|
||||||
/// <summary>
|
|
||||||
/// If the server has already been added
|
|
||||||
/// </summary>
|
|
||||||
bool added;
|
|
||||||
/// <summary>
|
|
||||||
/// if a request is currently sending
|
|
||||||
/// </summary>
|
|
||||||
bool sending;
|
|
||||||
/// <summary>
|
|
||||||
/// If an update request was recently sent
|
|
||||||
/// </summary>
|
|
||||||
bool skipNextPing;
|
|
||||||
/// <summary>
|
|
||||||
/// How many failed pings in a row
|
|
||||||
/// </summary>
|
|
||||||
int pingFails = 0;
|
|
||||||
|
|
||||||
public bool ServerInList => added;
|
|
||||||
|
|
||||||
public ListServerServerApi(ICoroutineRunner runner, IRequestCreator requestCreator) : base(runner, requestCreator)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Shutdown()
|
|
||||||
{
|
|
||||||
stopPingCoroutine();
|
|
||||||
if (added)
|
|
||||||
{
|
|
||||||
removeServerWithoutCoroutine();
|
|
||||||
}
|
|
||||||
added = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddServer(ServerJson server)
|
|
||||||
{
|
|
||||||
if (added) { Logger.LogWarning("AddServer called when server was already adding or added"); return; }
|
|
||||||
bool valid = server.Validate();
|
|
||||||
if (!valid) { return; }
|
|
||||||
|
|
||||||
runner.StartCoroutine(addServer(server));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateServer(int newPlayerCount)
|
|
||||||
{
|
|
||||||
if (!added) { Logger.LogWarning("UpdateServer called when before server was added"); return; }
|
|
||||||
|
|
||||||
currentServer.playerCount = newPlayerCount;
|
|
||||||
UpdateServer(currentServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateServer(ServerJson server)
|
|
||||||
{
|
|
||||||
// TODO, use PartialServerJson as Arg Instead
|
|
||||||
if (!added) { Logger.LogWarning("UpdateServer called when before server was added"); return; }
|
|
||||||
|
|
||||||
PartialServerJson partialServer = new PartialServerJson
|
|
||||||
{
|
|
||||||
displayName = server.displayName,
|
|
||||||
playerCount = server.playerCount,
|
|
||||||
maxPlayerCount = server.maxPlayerCount,
|
|
||||||
customData = server.customData,
|
|
||||||
};
|
|
||||||
partialServer.Validate();
|
|
||||||
|
|
||||||
runner.StartCoroutine(updateServer(partialServer));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveServer()
|
|
||||||
{
|
|
||||||
if (!added) { return; }
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(serverId))
|
|
||||||
{
|
|
||||||
Logger.LogWarning("Can not remove server because serverId was empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
stopPingCoroutine();
|
|
||||||
runner.StartCoroutine(removeServer());
|
|
||||||
}
|
|
||||||
|
|
||||||
void stopPingCoroutine()
|
|
||||||
{
|
|
||||||
if (_pingCoroutine != null)
|
|
||||||
{
|
|
||||||
runner.StopCoroutine(_pingCoroutine);
|
|
||||||
_pingCoroutine = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator addServer(ServerJson server)
|
|
||||||
{
|
|
||||||
added = true;
|
|
||||||
sending = true;
|
|
||||||
currentServer = server;
|
|
||||||
|
|
||||||
UnityWebRequest request = requestCreator.Post("servers", currentServer);
|
|
||||||
yield return requestCreator.SendRequestEnumerator(request, onSuccess, onFail);
|
|
||||||
sending = false;
|
|
||||||
|
|
||||||
void onSuccess(string responseBody)
|
|
||||||
{
|
|
||||||
CreatedIdJson created = JsonUtility.FromJson<CreatedIdJson>(responseBody);
|
|
||||||
serverId = created.id;
|
|
||||||
|
|
||||||
// Start ping to keep server alive
|
|
||||||
_pingCoroutine = runner.StartCoroutine(ping());
|
|
||||||
}
|
|
||||||
void onFail(string responseBody)
|
|
||||||
{
|
|
||||||
added = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator updateServer(PartialServerJson server)
|
|
||||||
{
|
|
||||||
// wait to not be sending
|
|
||||||
while (sending)
|
|
||||||
{
|
|
||||||
yield return new WaitForSeconds(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to check added in case Update is called soon after Add, and add failed
|
|
||||||
if (!added) { Logger.LogWarning("UpdateServer called when before server was added"); yield break; }
|
|
||||||
|
|
||||||
sending = true;
|
|
||||||
UnityWebRequest request = requestCreator.Patch("servers/" + serverId, server);
|
|
||||||
yield return requestCreator.SendRequestEnumerator(request, onSuccess);
|
|
||||||
sending = false;
|
|
||||||
|
|
||||||
void onSuccess(string responseBody)
|
|
||||||
{
|
|
||||||
skipNextPing = true;
|
|
||||||
|
|
||||||
if (_pingCoroutine == null)
|
|
||||||
{
|
|
||||||
_pingCoroutine = runner.StartCoroutine(ping());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Keeps server alive in database
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
IEnumerator ping()
|
|
||||||
{
|
|
||||||
while (pingFails <= MaxPingFails)
|
|
||||||
{
|
|
||||||
yield return new WaitForSeconds(PingInterval);
|
|
||||||
if (skipNextPing)
|
|
||||||
{
|
|
||||||
skipNextPing = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
sending = true;
|
|
||||||
UnityWebRequest request = requestCreator.Patch("servers/" + serverId, new EmptyJson());
|
|
||||||
yield return requestCreator.SendRequestEnumerator(request, onSuccess, onFail);
|
|
||||||
sending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.LogWarning("Max ping fails reached, stopping to ping server");
|
|
||||||
_pingCoroutine = null;
|
|
||||||
|
|
||||||
|
|
||||||
void onSuccess(string responseBody)
|
|
||||||
{
|
|
||||||
pingFails = 0;
|
|
||||||
}
|
|
||||||
void onFail(string responseBody)
|
|
||||||
{
|
|
||||||
pingFails++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator removeServer()
|
|
||||||
{
|
|
||||||
sending = true;
|
|
||||||
UnityWebRequest request = requestCreator.Delete("servers/" + serverId);
|
|
||||||
yield return requestCreator.SendRequestEnumerator(request);
|
|
||||||
sending = false;
|
|
||||||
|
|
||||||
added = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeServerWithoutCoroutine()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(serverId))
|
|
||||||
{
|
|
||||||
Logger.LogWarning("Can not remove server because serverId was empty");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnityWebRequest request = requestCreator.Delete("servers/" + serverId);
|
|
||||||
UnityWebRequestAsyncOperation operation = request.SendWebRequest();
|
|
||||||
|
|
||||||
operation.completed += (op) =>
|
|
||||||
{
|
|
||||||
Logger.LogResponse(request);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: 1f8b918bcd89f5c488b06f5574f34760
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ fileFormatVersion: 2
|
||||||
guid: 325984b52e4128546bc7558552f8b1d2
|
guid: 325984b52e4128546bc7558552f8b1d2
|
||||||
AssemblyDefinitionImporter:
|
AssemblyDefinitionImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: 9bee879fbc8ef4b1a9a9f7088bfbf726
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: b5dcf9618f5e14a4eb60bff5480284a6
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Mirror.Discovery
|
||||||
/// <see cref="NetworkDiscovery">NetworkDiscovery</see> for a sample implementation
|
/// <see cref="NetworkDiscovery">NetworkDiscovery</see> for a sample implementation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkDiscovery.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-discovery")]
|
||||||
public abstract class NetworkDiscoveryBase<Request, Response> : MonoBehaviour
|
public abstract class NetworkDiscoveryBase<Request, Response> : MonoBehaviour
|
||||||
where Request : NetworkMessage
|
where Request : NetworkMessage
|
||||||
where Response : NetworkMessage
|
where Response : NetworkMessage
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ namespace Mirror.Discovery
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkDiscoveryHUD")]
|
[AddComponentMenu("Network/NetworkDiscoveryHUD")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkDiscovery.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-discovery")]
|
||||||
[RequireComponent(typeof(NetworkDiscovery))]
|
[RequireComponent(typeof(NetworkDiscovery))]
|
||||||
public class NetworkDiscoveryHUD : MonoBehaviour
|
public class NetworkDiscoveryHUD : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: bfbf2a1f2b300c5489dcab219ef2846e
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||||
namespace Mirror.Experimental
|
namespace Mirror.Experimental
|
||||||
{
|
{
|
||||||
[AddComponentMenu("Network/Experimental/NetworkLerpRigidbody")]
|
[AddComponentMenu("Network/Experimental/NetworkLerpRigidbody")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkLerpRigidbody.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-lerp-rigidbody")]
|
||||||
public class NetworkLerpRigidbody : NetworkBehaviour
|
public class NetworkLerpRigidbody : NetworkBehaviour
|
||||||
{
|
{
|
||||||
[Header("Settings")]
|
[Header("Settings")]
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||||
namespace Mirror.Experimental
|
namespace Mirror.Experimental
|
||||||
{
|
{
|
||||||
[AddComponentMenu("Network/Experimental/NetworkRigidbody")]
|
[AddComponentMenu("Network/Experimental/NetworkRigidbody")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkRigidbody.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-rigidbody")]
|
||||||
public class NetworkRigidbody : NetworkBehaviour
|
public class NetworkRigidbody : NetworkBehaviour
|
||||||
{
|
{
|
||||||
[Header("Settings")]
|
[Header("Settings")]
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ namespace Mirror.Experimental
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/Experimental/NetworkTransformExperimental")]
|
[AddComponentMenu("Network/Experimental/NetworkTransformExperimental")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkTransform.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-transform")]
|
||||||
public class NetworkTransform : NetworkTransformBase
|
public class NetworkTransform : NetworkTransformBase
|
||||||
{
|
{
|
||||||
protected override Transform targetTransform => transform;
|
protected override Transform targetTransform => transform;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace Mirror.Experimental
|
||||||
/// <para>There must be a NetworkTransform on the root object of the hierarchy. There can be multiple NetworkTransformChild components on an object. This does not use physics for synchronization, it simply synchronizes the localPosition and localRotation of the child transform and lerps towards the received values.</para>
|
/// <para>There must be a NetworkTransform on the root object of the hierarchy. There can be multiple NetworkTransformChild components on an object. This does not use physics for synchronization, it simply synchronizes the localPosition and localRotation of the child transform and lerps towards the received values.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("Network/Experimental/NetworkTransformChildExperimentalExperimental")]
|
[AddComponentMenu("Network/Experimental/NetworkTransformChildExperimentalExperimental")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkTransformChild.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-transform-child")]
|
||||||
public class NetworkTransformChild : NetworkTransformBase
|
public class NetworkTransformChild : NetworkTransformBase
|
||||||
{
|
{
|
||||||
[Header("Target")]
|
[Header("Target")]
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: c66f27e006ab94253b39a55a3b213651
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: fa4cbc6b9c584db4971985cb9f369077
|
guid: fa4cbc6b9c584db4971985cb9f369077
|
||||||
timeCreated: 1613110605
|
timeCreated: 1613110605
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: cfa12b73503344d49b398b01bcb07967
|
guid: cfa12b73503344d49b398b01bcb07967
|
||||||
timeCreated: 1613110634
|
timeCreated: 1613110634
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@ fileFormatVersion: 2
|
||||||
guid: 72872094b21c16e48b631b2224833d49
|
guid: 72872094b21c16e48b631b2224833d49
|
||||||
AssemblyDefinitionImporter:
|
AssemblyDefinitionImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace Mirror
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[AddComponentMenu("Network/NetworkAnimator")]
|
[AddComponentMenu("Network/NetworkAnimator")]
|
||||||
[RequireComponent(typeof(NetworkIdentity))]
|
[RequireComponent(typeof(NetworkIdentity))]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkAnimator.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-animator")]
|
||||||
public class NetworkAnimator : NetworkBehaviour
|
public class NetworkAnimator : NetworkBehaviour
|
||||||
{
|
{
|
||||||
[Header("Authority")]
|
[Header("Authority")]
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace Mirror
|
||||||
/// <para>The OnLobby*() functions have empty implementations on the NetworkLobbyManager base class, so the base class functions do not have to be called.</para>
|
/// <para>The OnLobby*() functions have empty implementations on the NetworkLobbyManager base class, so the base class functions do not have to be called.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[AddComponentMenu("Network/NetworkLobbyManager")]
|
[AddComponentMenu("Network/NetworkLobbyManager")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkRoomManager.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-room-manager")]
|
||||||
[Obsolete("Use / inherit from NetworkRoomManager instead")]
|
[Obsolete("Use / inherit from NetworkRoomManager instead")]
|
||||||
public class NetworkLobbyManager : NetworkRoomManager {}
|
public class NetworkLobbyManager : NetworkRoomManager {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace Mirror
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkLobbyPlayer")]
|
[AddComponentMenu("Network/NetworkLobbyPlayer")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkRoomPlayer.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-room-player")]
|
||||||
[Obsolete("Use / inherit from NetworkRoomPlayer instead")]
|
[Obsolete("Use / inherit from NetworkRoomPlayer instead")]
|
||||||
public class NetworkLobbyPlayer : NetworkRoomPlayer {}
|
public class NetworkLobbyPlayer : NetworkRoomPlayer {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Mirror
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkMatchChecker")]
|
[AddComponentMenu("Network/NetworkMatchChecker")]
|
||||||
[RequireComponent(typeof(NetworkIdentity))]
|
[RequireComponent(typeof(NetworkIdentity))]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkMatchChecker.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-match-checker")]
|
||||||
public class NetworkMatchChecker : NetworkVisibility
|
public class NetworkMatchChecker : NetworkVisibility
|
||||||
{
|
{
|
||||||
static readonly Dictionary<Guid, HashSet<NetworkIdentity>> matchPlayers = new Dictionary<Guid, HashSet<NetworkIdentity>>();
|
static readonly Dictionary<Guid, HashSet<NetworkIdentity>> matchPlayers = new Dictionary<Guid, HashSet<NetworkIdentity>>();
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Mirror
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkOwnerChecker")]
|
[AddComponentMenu("Network/NetworkOwnerChecker")]
|
||||||
[RequireComponent(typeof(NetworkIdentity))]
|
[RequireComponent(typeof(NetworkIdentity))]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Components/NetworkOwnerChecker.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-owner-checker")]
|
||||||
public class NetworkOwnerChecker : NetworkVisibility
|
public class NetworkOwnerChecker : NetworkVisibility
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Mirror
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkPingDisplay")]
|
[AddComponentMenu("Network/NetworkPingDisplay")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkPingDisplay.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-ping-display")]
|
||||||
public class NetworkPingDisplay : MonoBehaviour
|
public class NetworkPingDisplay : MonoBehaviour
|
||||||
{
|
{
|
||||||
public Color color = Color.white;
|
public Color color = Color.white;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Mirror
|
||||||
[Obsolete(NetworkVisibilityObsoleteMessage.Message)]
|
[Obsolete(NetworkVisibilityObsoleteMessage.Message)]
|
||||||
[AddComponentMenu("Network/NetworkProximityChecker")]
|
[AddComponentMenu("Network/NetworkProximityChecker")]
|
||||||
[RequireComponent(typeof(NetworkIdentity))]
|
[RequireComponent(typeof(NetworkIdentity))]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkProximityChecker.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-proximity-checker")]
|
||||||
public class NetworkProximityChecker : NetworkVisibility
|
public class NetworkProximityChecker : NetworkVisibility
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Mirror
|
||||||
/// <para>The OnRoom*() functions have empty implementations on the NetworkRoomManager base class, so the base class functions do not have to be called.</para>
|
/// <para>The OnRoom*() functions have empty implementations on the NetworkRoomManager base class, so the base class functions do not have to be called.</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
[AddComponentMenu("Network/NetworkRoomManager")]
|
[AddComponentMenu("Network/NetworkRoomManager")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkRoomManager.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-room-manager")]
|
||||||
public class NetworkRoomManager : NetworkManager
|
public class NetworkRoomManager : NetworkManager
|
||||||
{
|
{
|
||||||
public struct PendingPlayer
|
public struct PendingPlayer
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace Mirror
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkRoomPlayer")]
|
[AddComponentMenu("Network/NetworkRoomPlayer")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkRoomPlayer.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-room-player")]
|
||||||
public class NetworkRoomPlayer : NetworkBehaviour
|
public class NetworkRoomPlayer : NetworkBehaviour
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Mirror
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkSceneChecker")]
|
[AddComponentMenu("Network/NetworkSceneChecker")]
|
||||||
[RequireComponent(typeof(NetworkIdentity))]
|
[RequireComponent(typeof(NetworkIdentity))]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkSceneChecker.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-scene-checker")]
|
||||||
public class NetworkSceneChecker : NetworkVisibility
|
public class NetworkSceneChecker : NetworkVisibility
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ namespace Mirror
|
||||||
{
|
{
|
||||||
[DisallowMultipleComponent]
|
[DisallowMultipleComponent]
|
||||||
[AddComponentMenu("Network/NetworkTransform")]
|
[AddComponentMenu("Network/NetworkTransform")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkTransform.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-transform")]
|
||||||
public class NetworkTransform : NetworkTransformBase
|
public class NetworkTransform : NetworkTransformBase
|
||||||
{
|
{
|
||||||
protected override Transform targetComponent => transform;
|
protected override Transform targetComponent => transform;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,10 @@ namespace Mirror
|
||||||
[Header("Interpolation")]
|
[Header("Interpolation")]
|
||||||
[Tooltip("Set to true if scale should be interpolated, false is ideal for instant sprite flipping.")]
|
[Tooltip("Set to true if scale should be interpolated, false is ideal for instant sprite flipping.")]
|
||||||
public bool interpolateScale = true;
|
public bool interpolateScale = true;
|
||||||
|
[Tooltip("Set to true if rotation should be interpolated, false is ideal for instant turning, common in retro 2d style games")]
|
||||||
|
public bool interpolateRotation = true;
|
||||||
|
[Tooltip("Set to true if position should be interpolated, false is ideal for grid bassed movement")]
|
||||||
|
public bool interpolatePosition = true;
|
||||||
|
|
||||||
[Header("Synchronization")]
|
[Header("Synchronization")]
|
||||||
// It should be very rare cases that people want to continuously sync scale, true by default to not break previous projects that use it
|
// It should be very rare cases that people want to continuously sync scale, true by default to not break previous projects that use it
|
||||||
|
|
@ -265,9 +269,13 @@ namespace Mirror
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector3 InterpolatePosition(DataPoint start, DataPoint goal, Vector3 currentPosition)
|
Vector3 InterpolatePosition(DataPoint start, DataPoint goal, Vector3 currentPosition)
|
||||||
{
|
{
|
||||||
if (start != null)
|
if (!interpolatePosition)
|
||||||
|
{
|
||||||
|
return goal.localPosition;
|
||||||
|
}
|
||||||
|
else if (start != null)
|
||||||
{
|
{
|
||||||
// Option 1: simply interpolate based on time. but stutter
|
// Option 1: simply interpolate based on time. but stutter
|
||||||
// will happen, it's not that smooth. especially noticeable if
|
// will happen, it's not that smooth. especially noticeable if
|
||||||
|
|
@ -284,9 +292,13 @@ namespace Mirror
|
||||||
return currentPosition;
|
return currentPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Quaternion InterpolateRotation(DataPoint start, DataPoint goal, Quaternion defaultRotation)
|
Quaternion InterpolateRotation(DataPoint start, DataPoint goal, Quaternion defaultRotation)
|
||||||
{
|
{
|
||||||
if (start != null)
|
if (!interpolateRotation)
|
||||||
|
{
|
||||||
|
return goal.localRotation;
|
||||||
|
}
|
||||||
|
else if (start != null)
|
||||||
{
|
{
|
||||||
float t = CurrentInterpolationFactor(start, goal);
|
float t = CurrentInterpolationFactor(start, goal);
|
||||||
return Quaternion.Slerp(start.localRotation, goal.localRotation, t);
|
return Quaternion.Slerp(start.localRotation, goal.localRotation, t);
|
||||||
|
|
@ -296,7 +308,15 @@ namespace Mirror
|
||||||
|
|
||||||
Vector3 InterpolateScale(DataPoint start, DataPoint goal, Vector3 currentScale)
|
Vector3 InterpolateScale(DataPoint start, DataPoint goal, Vector3 currentScale)
|
||||||
{
|
{
|
||||||
if (start != null && interpolateScale)
|
if (!syncScale)
|
||||||
|
{
|
||||||
|
return currentScale;
|
||||||
|
}
|
||||||
|
else if (!interpolateScale)
|
||||||
|
{
|
||||||
|
return goal.localScale;
|
||||||
|
}
|
||||||
|
else if (interpolateScale && start != null )
|
||||||
{
|
{
|
||||||
float t = CurrentInterpolationFactor(start, goal);
|
float t = CurrentInterpolationFactor(start, goal);
|
||||||
return Vector3.Lerp(start.localScale, goal.localScale, t);
|
return Vector3.Lerp(start.localScale, goal.localScale, t);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace Mirror
|
||||||
/// <para>There must be a NetworkTransform on the root object of the hierarchy. There can be multiple NetworkTransformChild components on an object. This does not use physics for synchronization, it simply synchronizes the localPosition and localRotation of the child transform and lerps towards the received values.</para>
|
/// <para>There must be a NetworkTransform on the root object of the hierarchy. There can be multiple NetworkTransformChild components on an object. This does not use physics for synchronization, it simply synchronizes the localPosition and localRotation of the child transform and lerps towards the received values.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("Network/NetworkTransformChild")]
|
[AddComponentMenu("Network/NetworkTransformChild")]
|
||||||
[HelpURL("https://mirror-networking.com/docs/Articles/Components/NetworkTransformChild.html")]
|
[HelpURL("https://mirror-networking.gitbook.io/docs/components/network-transform-child")]
|
||||||
public class NetworkTransformChild : NetworkTransformBase
|
public class NetworkTransformChild : NetworkTransformBase
|
||||||
{
|
{
|
||||||
[Header("Target")]
|
[Header("Target")]
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
icon: {fileID: 2800000, guid: 7453abfe9e8b2c04a8a47eb536fe21eb, type: 3}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,6 @@ guid: 2539267b6934a4026a505690a1e1eda2
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,6 @@ MonoImporter:
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData: ''
|
||||||
assetBundleName:
|
assetBundleName: ''
|
||||||
assetBundleVariant:
|
assetBundleVariant: ''
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue