File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
Assets/MixedRealityToolkit/Utilities/Async/Internal Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -48,22 +48,36 @@ internal static AsyncCoroutineRunner Instance
4848 if ( instance == null )
4949 {
5050 var instanceGameObject = GameObject . Find ( "AsyncCoroutineRunner" ) ;
51+
5152 if ( instanceGameObject != null )
5253 {
5354 instance = instanceGameObject . GetComponent < AsyncCoroutineRunner > ( ) ;
55+
5456 if ( instance == null )
5557 {
5658 Debug . Log ( "[AsyncCoroutineRunner] Found GameObject but didn't have component" ) ;
57- Destroy ( instanceGameObject ) ;
59+
60+ if ( Application . isPlaying )
61+ {
62+ Destroy ( instanceGameObject ) ;
63+ }
64+ else
65+ {
66+ DestroyImmediate ( instanceGameObject ) ;
67+ }
5868 }
5969 }
70+ }
6071
72+ if ( instance == null )
73+ {
6174 instance = new GameObject ( "AsyncCoroutineRunner" ) . AddComponent < AsyncCoroutineRunner > ( ) ;
62- instance . gameObject . hideFlags = HideFlags . HideInHierarchy ;
75+ }
76+
77+ instance . gameObject . hideFlags = HideFlags . None ;
6378#if ! UNITY_EDITOR
64- DontDestroyOnLoad ( instance ) ;
79+ DontDestroyOnLoad ( instance ) ;
6580#endif
66- }
6781
6882 return instance ;
6983 }
You can’t perform that action at this time.
0 commit comments