Is there a way to change EnableAdaptiveForce in PhysicsSettings from a script?
Typically yes. In this case there doesn’t seem to be a public API.
Most of these settings are actually stored with EditorPrefs. So it would require you to open Registry editor, navigate to the key where these are stored and then flip the setting and reload the Registry editor to see which value has changed. Sysinternals tools can help you figure these out as it will monitor read/writes to the registry (filtered by key).
Once you have the key you can use it with EditorPrefs. Mind you, you’ll have to remove the project specific trailing suffix of the key which looks something like “_384f2ad9”.
Some settings are stored in assets under ProjectSettings however. These are typically ScriptableObject instances and you’d likely have to find the corresponding type in the code and use reflection to access any internal or private properties/fields.
If you modify a setting via script with the respective settings tab open you will not notice the GUI changing unless you navigate away and back. Sometimes it even takes more than that because if you navigate away the settings script may actually save what the GUI currently displayed, thus overriding your change.
Is it really difficult to dynamically switch AdaptiveForce?
In some scenes, the behavior becomes unstable when AdaptiveForce is enabled, so I wanted to switch it dynamically.
Physics settings are stored in the file DynamicsManager.asset, which is in the folder ProjectSettings of each Unity project. You can load this file as SerializedObject from an Editor script, then access and modify its properties via SerializedObject.FindProperty(), and finally save the changes with SerializedObject.ApplyModifiedProperties().
Here’s an example code of how to modify project settings:
You can adapt that example code to open the file ProjectSettings\DynamicsManager.asset, then modify the int property m_EnableAdaptiveForce to 1.
Note that modifying Project Settings can only be done from the Unity Editor. There’s no way to modify the Project Settings from the built application, unless there’s a specific public API in UnityEngine for that (which isn’t the case for the adaptive force setting).