From f5089f14bc16207c0777b1b629f08aa7ce412e90 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Wed, 26 Jun 2024 20:44:29 -0400 Subject: [PATCH] fix(TopDownShooter): Use FindAnyObjectByType for Unity 2022.2+ --- Assets/Mirror/Examples/TopDownShooter/Scripts/EnemyTopDown.cs | 4 ++++ .../Mirror/Examples/TopDownShooter/Scripts/PlayerTopDown.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Assets/Mirror/Examples/TopDownShooter/Scripts/EnemyTopDown.cs b/Assets/Mirror/Examples/TopDownShooter/Scripts/EnemyTopDown.cs index bc3ce8a24..051a79d13 100644 --- a/Assets/Mirror/Examples/TopDownShooter/Scripts/EnemyTopDown.cs +++ b/Assets/Mirror/Examples/TopDownShooter/Scripts/EnemyTopDown.cs @@ -24,7 +24,11 @@ public class EnemyTopDown : NetworkBehaviour void Awake() { //allow all to run this, they may need it for reference +#if UNITY_2022_2_OR_NEWER + canvasTopDown = GameObject.FindAnyObjectByType(); +#else canvasTopDown = GameObject.FindObjectOfType(); +#endif } void Start() diff --git a/Assets/Mirror/Examples/TopDownShooter/Scripts/PlayerTopDown.cs b/Assets/Mirror/Examples/TopDownShooter/Scripts/PlayerTopDown.cs index 1eaeb6314..ae79d76cc 100644 --- a/Assets/Mirror/Examples/TopDownShooter/Scripts/PlayerTopDown.cs +++ b/Assets/Mirror/Examples/TopDownShooter/Scripts/PlayerTopDown.cs @@ -56,7 +56,11 @@ public override void OnStartLocalPlayer() void Awake() { // Allow all players to run this, they may need it for reference +#if UNITY_2022_2_OR_NEWER + canvasTopDown = GameObject.FindAnyObjectByType(); +#else canvasTopDown = GameObject.FindObjectOfType(); +#endif } public void Start()