@@ -41,10 +41,12 @@ const std::string& PathManager::GetExecutablePath()
41
41
42
42
bool PathManager::AutoDetectAssetsPath ()
43
43
{
44
- for (U32 i = 0 ; i < 5 ; ++i)
44
+ constexpr U32 kScanDepth = 5 ;
45
+
46
+ std::string backfolder = " " ;
47
+ for (U32 i = 0 ; i < kScanDepth ; ++i)
45
48
{
46
- std::string backfolder = " " ;
47
- for (U32 j = 0 ; j < i; ++j)
49
+ if (i > 0 )
48
50
{
49
51
backfolder += " ../" ;
50
52
}
@@ -56,15 +58,31 @@ bool PathManager::AutoDetectAssetsPath()
56
58
return true ;
57
59
}
58
60
}
59
-
60
- #if defined(ENLIVE_RELEASE )
61
- std::filesystem::path tempAssetsPath = std::filesystem::path ( GetCurrentPath () + " Assets " );
62
- if ( std::filesystem::exists (tempAssetsPath))
61
+
62
+ #if defined(ENLIVE_TOOL )
63
+ // Start backward to get the examples at the root instead of the one in the build folder
64
+ for (I32 i = static_cast <I32>( kScanDepth ); i > 0 ; --i)
63
65
{
64
- SetAssetsPath (tempAssetsPath.generic_string () + " /" );
65
- return true ;
66
+ if (i < 5 )
67
+ {
68
+ backfolder.resize (backfolder.size () - 3 );
69
+ }
70
+
71
+ std::filesystem::path tempCurrentExamplesPath = std::filesystem::path (GetCurrentPath () + backfolder + " examples" ).lexically_normal ();
72
+ if (std::filesystem::exists (tempCurrentExamplesPath))
73
+ {
74
+ SetAssetsPath (tempCurrentExamplesPath.generic_string () + " /" );
75
+ return true ;
76
+ }
77
+
78
+ std::filesystem::path tempExecutableExamplesPath = std::filesystem::path (GetExecutablePath () + backfolder + " examples" ).lexically_normal ();
79
+ if (std::filesystem::exists (tempExecutableExamplesPath))
80
+ {
81
+ SetAssetsPath (tempExecutableExamplesPath.generic_string () + " /" );
82
+ return true ;
83
+ }
66
84
}
67
- #endif // ENLIVE_RELEASE
85
+ #endif // ENLIVE_TOOL
68
86
69
87
return false ;
70
88
}
0 commit comments