mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: Safer version for FindAnyObjectByType (#3765)
Unity docs are a mess on when FindAnyObjectByType was implemented: - 2021.3 says it is - 2022.1 says it's not - 2022.2 says it is
This commit is contained in:
parent
2ed1d7329c
commit
490dea82ab
@ -30,7 +30,7 @@ public class PlayerPredicted : NetworkBehaviour
|
||||
void Awake()
|
||||
{
|
||||
// find the white ball once
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
whiteBall = FindAnyObjectByType<WhiteBallPredicted>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -83,7 +83,7 @@ public override void OnStartAuthority()
|
||||
characterController.enabled = true;
|
||||
this.enabled = true;
|
||||
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
sceneReferencer = GameObject.FindAnyObjectByType<SceneReferencer>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -10,7 +10,7 @@ public class PlayerEmpty : NetworkBehaviour
|
||||
public override void OnStartAuthority()
|
||||
{
|
||||
// enable UI located in the scene, after empty player spawns in.
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
sceneReferencer = GameObject.FindAnyObjectByType<SceneReferencer>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -26,7 +26,7 @@ public override void OnStartAuthority()
|
||||
|
||||
if (isOwned)
|
||||
{
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
couchPlayerManager = GameObject.FindAnyObjectByType<CouchPlayerManager>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -23,7 +23,7 @@ public class CouchPlayerManager : NetworkBehaviour
|
||||
public override void OnStartAuthority()
|
||||
{
|
||||
// hook up UI to local player, for cmd communication
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
canvasScript = GameObject.FindAnyObjectByType<CanvasScript>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -33,7 +33,7 @@ public class MatchController : NetworkBehaviour
|
||||
|
||||
void Awake()
|
||||
{
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
canvasController = GameObject.FindAnyObjectByType<CanvasController>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -19,7 +19,7 @@ public class MatchGUI : MonoBehaviour
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
canvasController = GameObject.FindAnyObjectByType<CanvasController>();
|
||||
#else
|
||||
// Deprecated in Unity 2023.1
|
||||
|
@ -188,7 +188,7 @@ private void OnClientDisconnect()
|
||||
// you first add this script to a gameobject.
|
||||
private void Reset()
|
||||
{
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
if (!FindAnyObjectByType<NetworkManager>())
|
||||
Debug.LogError("This component requires a NetworkManager component to be present in the scene. Please add!");
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user