@@ -45,10 +45,27 @@ public sealed class RenderStreaming : MonoBehaviour
45
45
[ InitializeOnLoadMethod ]
46
46
static void InitializeOnEditor ( )
47
47
{
48
+ /// todo(kazuki):: This is workaround.
49
+ /// When kicking the Unity Editor with batchmode flag on command line, The Unity Editor crashes
50
+ /// caused by not unloading WebRTC native plugin. By this workaround, Some static methods of this
51
+ /// package don't work correctly when batchmode. These static methods depend on WebRTC API,
52
+ /// therefore the package initialization must be completed just after launching Editor.
53
+ /// In the future, we will remove this workaround after improving the initialization of the
54
+ /// WebRTC package.
55
+ if ( ! IsYamato )
56
+ {
57
+ if ( Application . isBatchMode )
58
+ return ;
59
+ }
48
60
RenderStreamingInternal . DomainUnload ( ) ;
49
61
RenderStreamingInternal . DomainLoad ( ) ;
50
62
EditorApplication . quitting += RenderStreamingInternal . DomainUnload ;
51
63
}
64
+
65
+ /// <summary>
66
+ /// Executed from the auto testing environment or not.
67
+ /// </summary>
68
+ static bool IsYamato => ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "YAMATO_JOB_ID" ) ) ;
52
69
#else
53
70
[ RuntimeInitializeOnLoadMethod ]
54
71
static void InitializeOnRuntime ( )
@@ -59,19 +76,23 @@ static void InitializeOnRuntime()
59
76
}
60
77
#endif
61
78
62
- static Type GetType ( string typeName ) {
79
+ static Type GetType ( string typeName )
80
+ {
63
81
var type = Type . GetType ( typeName ) ;
64
82
if ( type != null ) return type ;
65
- foreach ( var assembly in System . AppDomain . CurrentDomain . GetAssemblies ( ) ) {
83
+ foreach ( var assembly in System . AppDomain . CurrentDomain . GetAssemblies ( ) )
84
+ {
66
85
type = assembly . GetType ( typeName ) ;
67
86
if ( type != null ) return type ;
68
87
}
69
88
return null ;
70
89
}
71
90
72
- static ISignaling CreateSignaling ( string type , string url , float interval , SynchronizationContext context ) {
91
+ static ISignaling CreateSignaling ( string type , string url , float interval , SynchronizationContext context )
92
+ {
73
93
Type _type = GetType ( type ) ;
74
- if ( _type == null ) {
94
+ if ( _type == null )
95
+ {
75
96
throw new ArgumentException ( $ "Signaling type is undefined. { type } ") ;
76
97
}
77
98
object [ ] args = { url , interval , context } ;
@@ -83,7 +104,7 @@ void Awake()
83
104
if ( ! runOnAwake || m_running )
84
105
return ;
85
106
86
- RTCConfiguration conf = new RTCConfiguration { iceServers = iceServers } ;
107
+ RTCConfiguration conf = new RTCConfiguration { iceServers = iceServers } ;
87
108
ISignaling signaling = CreateSignaling (
88
109
signalingType , urlSignaling , interval , SynchronizationContext . Current ) ;
89
110
_Run ( conf , signaling , handlers . ToArray ( ) ) ;
0 commit comments