mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix(NetworkDiscoveryHUD): More robust OnValidate / Reset
Handler would not be added if component ref not null.
This commit is contained in:
parent
fdc9369de4
commit
e6509cec34
@ -170,6 +170,8 @@ public void AdvertiseServer()
|
|||||||
MulticastLoopback = false
|
MulticastLoopback = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Debug.Log($"Discovery: Advertising Server {Dns.GetHostName()}");
|
||||||
|
|
||||||
// listen for client pings
|
// listen for client pings
|
||||||
_ = ServerListenAsync();
|
_ = ServerListenAsync();
|
||||||
}
|
}
|
||||||
@ -418,6 +420,7 @@ public void BroadcastDiscoveryRequest()
|
|||||||
|
|
||||||
ArraySegment<byte> data = writer.ToArraySegment();
|
ArraySegment<byte> data = writer.ToArraySegment();
|
||||||
|
|
||||||
|
//Debug.Log($"Discovery: Sending BroadcastDiscoveryRequest {request}");
|
||||||
clientUdpClient.SendAsync(data.Array, data.Count, endPoint);
|
clientUdpClient.SendAsync(data.Array, data.Count, endPoint);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Mirror.Discovery
|
namespace Mirror.Discovery
|
||||||
@ -17,11 +18,20 @@ public class NetworkDiscoveryHUD : MonoBehaviour
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
void OnValidate()
|
void OnValidate()
|
||||||
{
|
{
|
||||||
if (networkDiscovery == null)
|
if (Application.isPlaying) return;
|
||||||
|
Reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset()
|
||||||
{
|
{
|
||||||
networkDiscovery = GetComponent<NetworkDiscovery>();
|
networkDiscovery = GetComponent<NetworkDiscovery>();
|
||||||
|
|
||||||
|
// Add default event handler if not already present
|
||||||
|
if (!Enumerable.Range(0, networkDiscovery.OnServerFound.GetPersistentEventCount())
|
||||||
|
.Any(i => networkDiscovery.OnServerFound.GetPersistentMethodName(i) == "OnDiscoveredServer"))
|
||||||
|
{
|
||||||
UnityEditor.Events.UnityEventTools.AddPersistentListener(networkDiscovery.OnServerFound, OnDiscoveredServer);
|
UnityEditor.Events.UnityEventTools.AddPersistentListener(networkDiscovery.OnServerFound, OnDiscoveredServer);
|
||||||
UnityEditor.Undo.RecordObjects(new Object[] { this, networkDiscovery }, "Set NetworkDiscovery");
|
UnityEditor.Undo.RecordObjects(new UnityEngine.Object[] { this, networkDiscovery }, "Set NetworkDiscovery");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -125,6 +135,8 @@ void Connect(ServerResponse info)
|
|||||||
|
|
||||||
public void OnDiscoveredServer(ServerResponse info)
|
public void OnDiscoveredServer(ServerResponse info)
|
||||||
{
|
{
|
||||||
|
Debug.Log($"Discovered Server: {info.serverId} | {info.EndPoint} | {info.uri}");
|
||||||
|
|
||||||
// Note that you can check the versioning to decide if you can connect to the server or not using this method
|
// Note that you can check the versioning to decide if you can connect to the server or not using this method
|
||||||
discoveredServers[info.serverId] = info;
|
discoveredServers[info.serverId] = info;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ RenderSettings:
|
|||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 11
|
serializedVersion: 12
|
||||||
m_GIWorkflowMode: 0
|
m_GIWorkflowMode: 0
|
||||||
m_GISettings:
|
m_GISettings:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -98,7 +98,6 @@ LightmapSettings:
|
|||||||
m_TrainingDataDestination: TrainingData
|
m_TrainingDataDestination: TrainingData
|
||||||
m_LightProbeSampleCountMultiplier: 4
|
m_LightProbeSampleCountMultiplier: 4
|
||||||
m_LightingDataAsset: {fileID: 0}
|
m_LightingDataAsset: {fileID: 0}
|
||||||
m_UseShadowmask: 1
|
|
||||||
--- !u!196 &4
|
--- !u!196 &4
|
||||||
NavMeshSettings:
|
NavMeshSettings:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -118,6 +117,8 @@ NavMeshSettings:
|
|||||||
manualTileSize: 0
|
manualTileSize: 0
|
||||||
tileSize: 256
|
tileSize: 256
|
||||||
accuratePlacement: 0
|
accuratePlacement: 0
|
||||||
|
maxJobWorkers: 0
|
||||||
|
preserveTilesOutsideBounds: 0
|
||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
@ -433,8 +434,6 @@ MonoBehaviour:
|
|||||||
headlessStartMode: 1
|
headlessStartMode: 1
|
||||||
editorAutoStart: 0
|
editorAutoStart: 0
|
||||||
sendRate: 30
|
sendRate: 30
|
||||||
autoStartServerBuild: 0
|
|
||||||
autoConnectClientBuild: 0
|
|
||||||
offlineScene:
|
offlineScene:
|
||||||
onlineScene:
|
onlineScene:
|
||||||
offlineSceneLoadDelay: 0
|
offlineSceneLoadDelay: 0
|
||||||
@ -444,8 +443,7 @@ MonoBehaviour:
|
|||||||
disconnectInactiveConnections: 0
|
disconnectInactiveConnections: 0
|
||||||
disconnectInactiveTimeout: 60
|
disconnectInactiveTimeout: 60
|
||||||
authenticator: {fileID: 0}
|
authenticator: {fileID: 0}
|
||||||
playerPrefab: {fileID: 9081919128954505657, guid: ecd52c53a6ef7496693343d3e32dace1,
|
playerPrefab: {fileID: 9081919128954505657, guid: ecd52c53a6ef7496693343d3e32dace1, type: 3}
|
||||||
type: 3}
|
|
||||||
autoCreatePlayer: 1
|
autoCreatePlayer: 1
|
||||||
playerSpawnMethod: 0
|
playerSpawnMethod: 0
|
||||||
spawnPrefabs: []
|
spawnPrefabs: []
|
||||||
@ -508,6 +506,21 @@ MonoBehaviour:
|
|||||||
serverBroadcastListenPort: 47777
|
serverBroadcastListenPort: 47777
|
||||||
ActiveDiscoveryInterval: 3
|
ActiveDiscoveryInterval: 3
|
||||||
transport: {fileID: 1556883244}
|
transport: {fileID: 1556883244}
|
||||||
|
OnServerFound:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 1556883246}
|
||||||
|
m_TargetAssemblyTypeName: Mirror.Discovery.NetworkDiscoveryHUD, Mirror.Components
|
||||||
|
m_MethodName: OnDiscoveredServer
|
||||||
|
m_Mode: 0
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName:
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
secretHandshake: 1558261479176021378
|
secretHandshake: 1558261479176021378
|
||||||
--- !u!1 &1611696151
|
--- !u!1 &1611696151
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -628,6 +641,7 @@ Light:
|
|||||||
m_UseColorTemperature: 0
|
m_UseColorTemperature: 0
|
||||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||||
m_UseBoundingSphereOverride: 0
|
m_UseBoundingSphereOverride: 0
|
||||||
|
m_UseViewFrustumForShadowCasterCull: 1
|
||||||
m_ShadowRadius: 0
|
m_ShadowRadius: 0
|
||||||
m_ShadowAngle: 0
|
m_ShadowAngle: 0
|
||||||
--- !u!4 &1730851148
|
--- !u!4 &1730851148
|
||||||
|
Loading…
Reference in New Issue
Block a user