mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
CompilationFinishedHook caches last path in a project specific EditorPref to avoid having to search full project directory each time
This commit is contained in:
parent
5d2a6f8e94
commit
49ff55312f
@ -77,8 +77,44 @@ static string FindMirrorRuntime()
|
||||
// -> we have Runtime and Runtime-Editor dll. it doesn't matter
|
||||
// which one we use, so let's always use the one that is found
|
||||
// first
|
||||
|
||||
// searching huge project directories can be expensive, so let's use
|
||||
// EditorPrefs to try the last working one first
|
||||
// -> EditorPrefs are global across projects. we only care about the
|
||||
// path for this project though. otherwise switching between two
|
||||
// projects would need path to be searched again each time
|
||||
// -> use project GUID to make project specific paths
|
||||
string key = PlayerSettings.productGUID + ".LastMirrorRuntimeDll";
|
||||
if (EditorPrefs.HasKey(key))
|
||||
{
|
||||
string lastPath = EditorPrefs.GetString(key);
|
||||
if (File.Exists(lastPath))
|
||||
{
|
||||
return lastPath;
|
||||
}
|
||||
}
|
||||
|
||||
// search directory
|
||||
string[] files = Directory.GetFiles("Assets", "Mirror.Runtime.dll", SearchOption.AllDirectories);
|
||||
return files.Length > 0 ? files[0] : "";
|
||||
if (files.Length > 0)
|
||||
{
|
||||
// save path for next time, but only if it's a relative path.
|
||||
// we don't want to use another project's dlls for weaving, that
|
||||
// would be debugging hell.
|
||||
// (Directory.GetFiles should return relative paths)
|
||||
if (!Path.IsPathRooted(files[0]))
|
||||
{
|
||||
EditorPrefs.SetString(key, files[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Weaving doesn't cache path because it's absolute: " + files[0]);
|
||||
}
|
||||
|
||||
return files[0];
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user