How do I change Api Compatibility Level before Unity starts?

I want to upload a couple of DLL before Unity launch but the depend on .NET 2.0, not subnet of .NET 2.0, so I run this script:

UnityEditor.PlayerSettings.apiCompatibilityLevel = UnityEditor.ApiCompatibilityLevel.NET_2_0;

The problem is that I need this to be changed before Unity fully launches, since my dependent DLLs will fail to load if I don’t change it. [InitializeOnLoad] did not help.

Not sure if this would fix your specific problem but in your build settings, you can specify the full .net 2.0 package rather than the subset.

That’s exactly what I want to do! But I need this to be automatically done before Unity launches or my DLLs won’t work, or after. I need this to be done before I play any scene in editor.