Skip to content

Commit

Permalink
Moved initialization from Start() to Awake() (googleforgames#1338)
Browse files Browse the repository at this point in the history
Awake() is more commonly used to initialize variables as it is
guaranteed to run as soon as the game object is instantiated or
activated. Start() is called before the first Update(), which
might be up to a frame later.

See Unity docs for reference
https://docs.unity3d.com/ScriptReference/MonoBehaviour.Awake.html
  • Loading branch information
mollstam authored and ilkercelikyilmaz committed Oct 23, 2020
1 parent 23c19ea commit 44b5406
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sdks/unity/AgonesSdk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ private struct KeyValueMessage

#region Unity Methods
// Use this for initialization.
private void Start()
private void Awake()
{
String port = Environment.GetEnvironmentVariable("AGONES_SDK_HTTP_PORT");
sidecarAddress = "http://localhost:" + (port ?? "9358");
}

private void Start()
{
HealthCheckAsync();
}

Expand Down

0 comments on commit 44b5406

Please sign in to comment.