Closed JKohlman closed 1 year ago
Currently as it stands reading from the keyboard (Input.GetKeyDown, etc..) appears to be, at best, very difficult from a custom drawer without requiring a reference to ConfigurationManager.dll.
Input.GetKeyDown
The main root of this lies in the config manager OnGUI at https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/da2fc62b987565d0296f9cbbc17789ca944fe92b/ConfigurationManager/ConfigurationManager.cs#L273-L274 which resets the keyboard inputs every frame. This is easy to work around in a global drawer by including ConfigurationManager.dll and simply setting SettingFieldDrawer._currentKeyboardShortcutToSet to your current SettingEntryBase. https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/da2fc62b987565d0296f9cbbc17789ca944fe92b/ConfigurationManager/SettingFieldDrawer.cs#L27-L28 HOWEVER, in a drawer that is not global and does not include ConfigurationManager.dll, the signature is:
SettingFieldDrawer._currentKeyboardShortcutToSet
SettingEntryBase
static void CustomDrawer(BepInEx.Configuration.ConfigEntryBase entry)
And of course since the type is different you can no longer simply set that variable.
If there is an easy workaround that I'm missing I'd gladly make use of it but I can't seem to find one.
Currently as it stands reading from the keyboard (
Input.GetKeyDown
, etc..) appears to be, at best, very difficult from a custom drawer without requiring a reference to ConfigurationManager.dll.The main root of this lies in the config manager OnGUI at https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/da2fc62b987565d0296f9cbbc17789ca944fe92b/ConfigurationManager/ConfigurationManager.cs#L273-L274 which resets the keyboard inputs every frame. This is easy to work around in a global drawer by including ConfigurationManager.dll and simply setting
SettingFieldDrawer._currentKeyboardShortcutToSet
to your currentSettingEntryBase
. https://github.com/BepInEx/BepInEx.ConfigurationManager/blob/da2fc62b987565d0296f9cbbc17789ca944fe92b/ConfigurationManager/SettingFieldDrawer.cs#L27-L28 HOWEVER, in a drawer that is not global and does not include ConfigurationManager.dll, the signature is:And of course since the type is different you can no longer simply set that variable.
If there is an easy workaround that I'm missing I'd gladly make use of it but I can't seem to find one.