handzlikchris / handzlikchris/FastScriptReload

Improvement: FindFileOrThrow for dotnet tools caching result between project sessions

Offen
#171 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C#
Sterne
2.2k
Forks
167
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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;
}

```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp, unity
Bereich
game-dev, tooling
Issue-Typ
Feature
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.