Search Unity

EventSystem.current printing null

Discussion in 'Input System' started by the_mr_matt, Aug 1, 2020.

  1. the_mr_matt

    the_mr_matt

    Joined:
    Jul 21, 2015
    Posts:
    124
    Code (CSharp):
    1. private void OnEnable()
    2. {
    3.     Debug.Log(EventSystem.current);
    4.     EventSystem.current.SetSelectedGameObject(gameObject);
    5. }
    Very simple script for selecting a UI element on enable. However, EventSystem.current prints null to the console.

    Unity 2019.3.15f1
    I have an Rewired event system in the scene.

    Also tried putting this in an IEnumerator and waiting a frame before logging to the console - no change.
     
    Last edited: Aug 1, 2020