mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
Add headless check to Discovery (#1485)
This commit is contained in:
parent
9f7c30c1ac
commit
90d92fc0cf
@ -22,7 +22,7 @@ public class NetworkDiscovery : NetworkDiscoveryBase<ServerRequest, ServerRespon
|
||||
[Tooltip("Invoked when a server is found")]
|
||||
public ServerFoundUnityEvent OnServerFound;
|
||||
|
||||
public void Start()
|
||||
public override void Start()
|
||||
{
|
||||
ServerId = RandomLong();
|
||||
|
||||
@ -31,6 +31,8 @@ public void Start()
|
||||
// Or just let the user assign it in the inspector
|
||||
if (transport == null)
|
||||
transport = Transport.activeTransport;
|
||||
|
||||
base.Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -57,6 +57,18 @@ public static long RandomLong()
|
||||
return value1 + ((long)value2 << 32);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// virtual so that inheriting classes' Start() can call base.Start() too
|
||||
/// </summary>
|
||||
public virtual void Start()
|
||||
{
|
||||
// headless mode? then start advertising
|
||||
if (NetworkManager.isHeadless)
|
||||
{
|
||||
AdvertiseServer();
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the ports are cleared no matter when Game/Unity UI exits
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user