mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
feat(NetworkManager): Ability to toggle auto-start in Editor (#3694)
* feat(NetworkManager): Ability to toggle auto-start in Editor * use Application.isEditor --------- Co-authored-by: mischa <info@noobtuts.com>
This commit is contained in:
parent
92b99335d8
commit
ab99215e68
@ -29,11 +29,14 @@ public class NetworkManager : MonoBehaviour
|
|||||||
public bool runInBackground = true;
|
public bool runInBackground = true;
|
||||||
|
|
||||||
/// <summary>Should the server auto-start when 'Server Build' is checked in build settings</summary>
|
/// <summary>Should the server auto-start when 'Server Build' is checked in build settings</summary>
|
||||||
[Header("Headless Builds")]
|
[Header("Auto-Start Options")]
|
||||||
|
|
||||||
[Tooltip("Choose whether Server or Client should auto-start in headless builds")]
|
[Tooltip("Choose whether Server or Client should auto-start in headless builds")]
|
||||||
public HeadlessStartOptions headlessStartMode = HeadlessStartOptions.DoNothing;
|
public HeadlessStartOptions headlessStartMode = HeadlessStartOptions.DoNothing;
|
||||||
|
|
||||||
|
[Tooltip("Headless Start Mode in Editor\nwhen enabled, headless start mode will be used in editor as well.")]
|
||||||
|
public bool editorAutoStart;
|
||||||
|
|
||||||
/// <summary>Server Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.</summary>
|
/// <summary>Server Update frequency, per second. Use around 60Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.</summary>
|
||||||
[Tooltip("Server & Client send rate per second. Use 60-100Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")]
|
[Tooltip("Server & Client send rate per second. Use 60-100Hz for fast paced games like Counter-Strike to minimize latency. Use around 30Hz for games like WoW to minimize computations. Use around 1-10Hz for slow paced games like EVE.")]
|
||||||
[FormerlySerializedAs("serverTickRate")]
|
[FormerlySerializedAs("serverTickRate")]
|
||||||
@ -256,20 +259,20 @@ public virtual void Start()
|
|||||||
// We can't do this in Awake because Awake is for initialization
|
// We can't do this in Awake because Awake is for initialization
|
||||||
// and some transports might not be ready until Start.
|
// and some transports might not be ready until Start.
|
||||||
//
|
//
|
||||||
// don't auto start in editor where we have a UI, only in builds.
|
// Auto-starting in Editor is useful for debugging, so that can
|
||||||
// otherwise if we switch to 'Dedicated Server' target and press
|
// be enabled with editorAutoStart.
|
||||||
// Play, it would auto start the server every time.
|
|
||||||
if (Utils.IsHeadless())
|
if (Utils.IsHeadless())
|
||||||
{
|
{
|
||||||
switch (headlessStartMode)
|
if (!Application.isEditor || editorAutoStart)
|
||||||
{
|
switch (headlessStartMode)
|
||||||
case HeadlessStartOptions.AutoStartServer:
|
{
|
||||||
StartServer();
|
case HeadlessStartOptions.AutoStartServer:
|
||||||
break;
|
StartServer();
|
||||||
case HeadlessStartOptions.AutoStartClient:
|
break;
|
||||||
StartClient();
|
case HeadlessStartOptions.AutoStartClient:
|
||||||
break;
|
StartClient();
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user