You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Debug.Assert(instances.Length<=1,"[AsyncCoroutineRunner] There should only be one AsyncCoroutineRunner in the scene.");
58
+
instance=instances.Length==1?instances[0]:null;
59
+
if(instance!=null&&!instance.enabled)
60
+
{
61
+
Debug.LogWarning("[AsyncCoroutineRunner] Found a disabled AsyncCoroutineRunner component. Enabling the component.");
62
+
instance.enabled=true;
63
+
}
55
64
}
56
65
66
+
// FindObjectOfType() only search for objects attached to active GameObjects. The FindObjectOfType(bool includeInactive) variant is not available to Unity 2019.4 and earlier so cannot be used.
67
+
// We instead search for GameObject called AsyncCoroutineRunner and see if it has the component attached.
Debug.Log("[AsyncCoroutineRunner] Found GameObject but didn't have component");
68
-
69
-
if(Application.isPlaying)
78
+
Debug.Log("[AsyncCoroutineRunner] Found a \"AsyncCoroutineRunner\" GameObject but didn't have the AsyncCoroutineRunner component attached. Attaching the script.");
Debug.LogWarning("[AsyncCoroutineRunner] Found a disabled AsyncCoroutineRunner component. Enabling the component.");
86
+
instance.enabled=true;
72
87
}
73
-
else
88
+
if(!instanceGameObject.activeSelf)
74
89
{
75
-
DestroyImmediate(instanceGameObject);
90
+
Debug.LogWarning("[AsyncCoroutineRunner] Found an AsyncCoroutineRunner attached to an inactive GameObject. Setting the GameObject active.");
91
+
instanceGameObject.SetActive(true);
76
92
}
77
93
}
78
94
}
79
95
}
80
96
81
97
if(instance==null)
82
98
{
99
+
Debug.Log("[AsyncCoroutineRunner] There is no AsyncCoroutineRunner in the scene. Adding a GameObject with AsyncCoroutineRunner attached at the root of the scene.");
0 commit comments