@@ -68,7 +68,7 @@ public override VisualElement CreateInspectorGUI()
68
68
path = "./StreamingAssets/" + path . Split ( "StreamingAssets/" ) [ 1 ] ;
69
69
70
70
var machineFolderProp = serializedObject . FindProperty (
71
- $ "_mpfStarter ._machineFolder"
71
+ $ "_mpfWrangler ._machineFolder"
72
72
) ;
73
73
machineFolderProp . stringValue = path ;
74
74
serializedObject . ApplyModifiedProperties ( ) ;
@@ -195,6 +195,9 @@ ex is RpcException exception
195
195
executableSourceProp ,
196
196
OnExecutableSourceChanged
197
197
) ;
198
+
199
+ MachineFolderValidationBoxes ( machineFolderField ) ;
200
+
198
201
return root ;
199
202
}
200
203
@@ -255,5 +258,44 @@ private void UpdateGameItemList(VisualElement parent, IEnumerable<string> itemId
255
258
parent . Add ( label ) ;
256
259
}
257
260
}
261
+
262
+ private void MachineFolderValidationBoxes ( VisualElement machineFolderField )
263
+ {
264
+ var machineFolderProp = serializedObject . FindProperty ( $ "_mpfWrangler._machineFolder") ;
265
+ var notAMachineFolderErrorBox = new HelpBox (
266
+ "The machine folder is not valid. It must contain a folder called 'config' "
267
+ + "with at least one .yaml file inside." ,
268
+ HelpBoxMessageType . Error
269
+ ) ;
270
+ var streamingAssetsWarnBox = new HelpBox (
271
+ "The machine folder is not located in the 'StreamingAssets' folder. It will not be"
272
+ + " included in builds." ,
273
+ HelpBoxMessageType . Warning
274
+ ) ;
275
+ streamingAssetsWarnBox . TrackPropertyValue ( machineFolderProp , UpdateVisibility ) ;
276
+ var container = machineFolderField . parent ;
277
+ var index = container . IndexOf ( machineFolderField ) ;
278
+ container . Insert ( index , notAMachineFolderErrorBox ) ;
279
+ container . Insert ( index + 1 , streamingAssetsWarnBox ) ;
280
+ UpdateVisibility ( machineFolderProp ) ;
281
+
282
+ void UpdateVisibility ( SerializedProperty _ )
283
+ {
284
+ var machineFolder = _mpfEngine . MachineFolder ;
285
+ var isMachineFolderInStreamingAssets = machineFolder . StartsWith (
286
+ Application . streamingAssetsPath
287
+ ) ;
288
+ streamingAssetsWarnBox . style . display = isMachineFolderInStreamingAssets
289
+ ? DisplayStyle . None
290
+ : DisplayStyle . Flex ;
291
+
292
+ var configDir = Path . Combine ( machineFolder , "config" ) ;
293
+ var isValidMachineFolder =
294
+ Directory . Exists ( configDir ) && Directory . GetFiles ( configDir , "*.yaml" ) . Any ( ) ;
295
+ notAMachineFolderErrorBox . style . display = isValidMachineFolder
296
+ ? DisplayStyle . None
297
+ : DisplayStyle . Flex ;
298
+ }
299
+ }
258
300
}
259
301
}
0 commit comments