|
Post by alexr1221 on Dec 16, 2019 13:10:11 GMT
Hello,
I would like to share another version of the GenericInput class. It is more flexible (not constrained by any Input sytem (unity's input, ...), faster and more straightforward compared to the other one.
[System.Serializable]
public class NewGenericInput
{
public delegate float getFloat();
public getFloat GetAxisRaw; // Universal
private getFloat GetAxisRaw_Keyboard;
private getFloat GetAxisRaw_Mobile;
private getFloat GetAxisRaw_Joystick;
public NewGenericInput(getFloat keyboardGetAxisRaw, getFloat mobileGetAxisRaw, getFloat joystickGetAxisRaw)
{
GetAxisRaw_Keyboard = keyboardGetAxisRaw;
GetAxisRaw_Mobile = mobileGetAxisRaw;
GetAxisRaw_Joystick = joystickGetAxisRaw;
SetInputType(vInput.instance.inputDevice);
vInput.instance.onChangeInputType += (input) => SetInputType(input);
}
void SetInputType(InputDevice newType)
{
switch (newType)
{
case InputDevice.MouseKeyboard:
GetAxisRaw = GetAxisRaw_Keyboard;
break;
case InputDevice.Mobile:
GetAxisRaw = GetAxisRaw_Mobile;
break;
case InputDevice.Joystick:
GetAxisRaw = GetAxisRaw_Joystick;
break;
}
}
}
// usage: public NewGenericInput horizontalInput = new NewGenericInput(() => Input.GetAxisRaw("Horizontal"), () => CrossPlatformInputManager.GetAxisRaw("Horizontal"), () => InputRewired.gamepad.leftStick.value.x);
float valX = horizontal.GetAxisRaw(); Any chances to get it implemented officially?
|
|
|
Post by Invector on Dec 16, 2019 19:28:05 GMT
We don't have any plans to mess with the Input System right now since it's working quite well for now, and pretty soon Unity will officially change the InputManager, so we will have to work on that as well, plus these changes are only to Axis, I'm right?
I will make the Input methods public virtual so you can override and do the changes you need for the next update, this will make things better without changing too much of the core which people usually complain a lot every time we do xD
|
|
|
Post by alexr1221 on Dec 17, 2019 17:11:45 GMT
Thanks for the reply. This is not only for Axis but for everything, this was just an example. It was supposed to fully replace the old one.
Thanks but I think it's better to just replace all of the objects manually by myself. I shared this code to know whether it would be also suited for the asset officially.
I like this asset but I'm so frustrated to see that the code is often not optimized and not well designed. I understand it is not easy when you have a lot of assets sharing the same code to change things but you should really consider diving into it and cleaning the code regulary.
|
|