@@ -101,7 +101,7 @@ public static void OnPostprocessAllAssets(string[] importedAssets, string[] dele
101101 private static Task searchForFoldersTask = null ;
102102 private static CancellationTokenSource searchForFoldersToken ;
103103
104- private static string NormalizeSeparators ( string path ) =>
104+ private static string NormalizeSeparators ( string path ) =>
105105 path ? . Replace ( '\\ ' , Path . DirectorySeparatorChar ) . Replace ( '/' , Path . DirectorySeparatorChar ) ;
106106
107107 private static string FormatSeparatorsForUnity ( string path ) => path ? . Replace ( '\\ ' , '/' ) ;
@@ -350,6 +350,19 @@ public static MixedRealityToolkitModuleType GetModuleFromPackageFolder(string pa
350350 return moduleNameMap . TryGetValue ( packageFolder , out moduleType ) ? moduleType : MixedRealityToolkitModuleType . None ;
351351 }
352352
353+ /// <summary>
354+ /// Creates the MixedRealityToolkit.Generated folder if it does not exist and returns the
355+ /// path to the generated folder.
356+ /// </summary>
357+ public static string GetGeneratedFolder
358+ {
359+ get
360+ {
361+ TryToCreateGeneratedFolder ( ) ;
362+ return MapModulePath ( MixedRealityToolkitModuleType . Generated ) ;
363+ }
364+ }
365+
353366 private static async Task SearchForFoldersAsync ( string rootPath )
354367 {
355368 if ( searchForFoldersToken != null )
@@ -376,6 +389,9 @@ private static void SearchForFolders(string rootPath, CancellationToken ct)
376389 ct . ThrowIfCancellationRequested ( ) ;
377390 }
378391 }
392+
393+ // Create the Generated folder, if the user tries to delete the Generated folder it will be created again
394+ TryToCreateGeneratedFolder ( ) ;
379395 }
380396 catch ( OperationCanceledException )
381397 {
@@ -408,20 +424,15 @@ private static void RegisterFolderToModule(string folderPath, MixedRealityToolki
408424 }
409425
410426 modFolders . Add ( normalizedFolder ) ;
411-
412- if ( module == MixedRealityToolkitModuleType . Core )
413- {
414- TryToCreateGeneratedFolder ( folderPath ) ;
415- }
416427 }
417428
418- private static void TryToCreateGeneratedFolder ( string folderPath )
429+ private static void TryToCreateGeneratedFolder ( )
419430 {
431+ // Always add the the MixedRealityToolkit.Generated folder to Assets
420432 var generatedDirs = GetDirectories ( MixedRealityToolkitModuleType . Generated ) ;
421433 if ( generatedDirs == null || ! generatedDirs . Any ( ) )
422434 {
423- string parentFolderPath = Directory . GetParent ( folderPath ) . FullName ;
424- string generatedFolderPath = Path . Combine ( parentFolderPath , "MixedRealityToolkit.Generated" ) ;
435+ string generatedFolderPath = Path . Combine ( "Assets" , "MixedRealityToolkit.Generated" ) ;
425436 if ( ! Directory . Exists ( generatedFolderPath ) )
426437 {
427438 Directory . CreateDirectory ( generatedFolderPath ) ;
0 commit comments