- Home /
Question by
just_kenned · Dec 05, 2021 at 06:43 PM ·
inputinputmanagermissingreferenceexception
Why Player input aways get MissingReferenceException?
I started using PlayerInput yesterday but I've been having some problems like it regarding MissingReferenceException
protected void Awake()
{
manager = GetComponent<P_Manager>();
if(playerInput != null && gameObject != null){
medoAction = playerInput.actions["medo"];
}
}
private void OnEnable(){
//works
medoAction.canceled += ctx => SimpleFreeze();
// dont works
medoAction.canceled += ctx => manager.medo.SimpleFreeze();
}
private void SimpleFreeze(){
if(manager.medo != null) manager.medo.SimpleFreeze();
}
In the example above the code that checks if "manager.medo" is null before running works but the other one doesn't, I know that "manager.medo" is never null but if it doesn't check it accuses as null I would have something I can try to avoid so many "ifs" since i know "manager" or "manager.medo" is never null?
Sorry for bad english.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613050234im_/https://answers.unity.com/themes/thub/images/avi.jpg)