Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 32400bc

Browse files
committed
Added [DefaultExecutionOrder(-50)] to MonoSingleton
Afaik, this causes no harm and ensures the singleton functions(such as Awake, Update etc.) are executed before other classes. This can be changed in inherited classes if needed, but in 99% of the cases, I would say that you'd want the singleton to execute first. -50 seemed like a reasonable choice due to certain built in classes utilizing up to -100(e.g. UnityEngine.InputSystem.PlayerInput) and this way we still get plenty of free room around the singleton.
1 parent 9416bf6 commit 32400bc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

‎Runtime/Scripts/MonoSingleton.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace UnityCommunity.UnitySingleton
66
/// The basic MonoBehaviour singleton implementation, this singleton is destroyed after scene changes, use <see cref="PersistentMonoSingleton{T}"/> if you want a persistent and global singleton instance.
77
/// </summary>
88
/// <typeparam name="T"></typeparam>
9+
[DefaultExecutionOrder(-50)]
910
public abstract class MonoSingleton<T> : MonoBehaviour, ISingleton where T : MonoSingleton<T>
1011
{
1112
#region Fields
@@ -147,4 +148,4 @@ public static void DestroyInstance()
147148

148149
#endregion
149150
}
150-
}
151+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /