handzlikchris / handzlikchris/FastScriptReload

Improvement: FindFileOrThrow for dotnet tools caching result between project sessions

Aperta
#171 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
C#
Stelle
2.2k
Fork
167
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi, handzlikchris. Thank you for your excellent work.

I noticed that every time project opens, FSR always search deeply into Unity installation path for dotnet tools, which spends seconds to complete. Because of storing in `SessionState`, first-time project launch can't benefit from it.

In my opinion, utilize `EditorPrefs` with `unityVersion` could be better.

Here is my snippet for this:

```csharp
private static string FindFileOrThrow(string fileName)
{
var cacheKey = $"FSR:FilePath_{fileName}:{Application.unityVersion}";
var result = EditorPrefs.GetString(cacheKey, null);

if (result != null && !File.Exists(result))
{
EditorPrefs.DeleteKey(cacheKey);
result = null;
}

if (result == null)
{
result = Directory
.GetFiles(ApplicationContentsPath, fileName, SearchOption.AllDirectories)
.FirstOrDefault();

if (result == null)
{
throw new Exception($"Unable to find '{fileName}', make sure Editor version supports it. You can also add preprocessor directive 'FastScriptReload_CompileViaMCS' which will use Mono compiler instead");
}
}

EditorPrefs.SetString(cacheKey, result);
return result;
}

```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Locate the FindFileOrThrow implementation and inspect how SessionState currently stores the result. Verify the cache is scoped to the Unity version, invalidates missing paths, and avoids the deep search after reopening a project; manually test first launch and subsequent project sessions.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, unity
Ambito
game-dev, tooling
Tipo di issue
Funzionalità
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.