Equal execution values are not a contract
Unity defines the event-function flow, but it does not guarantee the relative order of different scripts that share the same execution value. A sequence that looks stable in the Editor can change in a build or after a scene layout changes. Renaming Awake or Start does not express a dependency.
using System;
using UnityEngine;
[DefaultExecutionOrder(-100)]
public sealed class GameBootstrap : MonoBehaviour
{
public static bool IsReady { get; private set; }
public static event Action Ready;
private void Awake()
{
IsReady = true;
Ready?.Invoke();
}
}Signal readiness before consuming the data
Use Script Execution Order for the few dependencies that are truly global. For other cases, an event or an explicit Initialize call is easier to read and test. The consumer below handles both a late subscription and an event that has not fired yet.
using UnityEngine;
public sealed class HudBinder : MonoBehaviour
{
[SerializeField] private GameObject panel;
private void OnEnable()
{
GameBootstrap.Ready += Show;
if (GameBootstrap.IsReady)
Show();
}
private void OnDisable()
{
GameBootstrap.Ready -= Show;
}
private void Show()
{
panel.SetActive(true);
}
}Check both configuration places
The value from DefaultExecutionOrder does not appear automatically in the Project Settings list. If the same type has a different value saved in the Editor UI, the UI value wins. After changing a number, inspect both places and test additive scene loading as well.