The script above was breaking every time anything reloaded and you’d need to click something inside the project folder for it to sort.
So instead i just directly modified UnityEngine.CoreModule.dll using dnSpy:
(Applications/Unity/Hub/Editor/2021.3.9f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.CoreModule.dll)
(For 2022+ it’s UnityEditor.CoreModule.dll)
UnityEditor → ProjectBrowser → GetShouldShowFoldersFirst() → right click → Edit IL instructions → replace instructions with “ldc.i4.1”, “ret” (meaning ‘return true;’).
File > Save Module, replace the dll. Have windows style sorting forever without any scripts. Works with Unity 2021.3.9f1 for me.
//Before this I also tried a bunch of things like: Harmony to inject stuff into this method using a script (Harmony doesn’t work on M1 turns out), tried same with Mono.Cecil (turns out the core .dll is unreachable for modifications from there or something like that). dnSpy to the rescue, one less annoying thing about macOS.
