I have my own input system and I’m trying to get the StandaloneInputModule to read from it instead from Input.GetAxis etc. I know that in order to do that, I need to inherit from BaseInput: Redirecting to latest version of com.unity.ugui
I’ve already done that but how do I tell the StandaloneInputModule to read from my custom class? Even if I attach my inherited component to the StandaloneInputModule’s gameobject, it still spawns its own BaseInput component and reads from it.
You can set property StandaloneInputModule.inputOverride for this. I think that should be the preferred way, since, in contrast to m_InputOverride, it is documented in the API.
If, for example, your BaseInput inherited Object is attached to the same GameObject as your StandaloneInputModule you could do the following:
public class CustomBaseInput : BaseInput
{
protected override void Awake() {
StandaloneInputModule standaloneInputModule = GetComponent<StandaloneInputModule>();
if (standaloneInputModule) standaloneInputModule.inputOverride = this;
}
public override float GetAxisRaw(string axisName) {
if (axisName=="Horizontal") {
// your code here
} else if (axisName=="Vertical") {
// your code here
}
return 0f;
}
public override bool GetButtonDown(string buttonName) {
if (buttonName=="Submit") {
// your code here
} else if (buttonName=="Cancel") {
// your code here
}
return false;
}
// more overrides as needed
}