Search Unity

How to set the current event to a new event

Discussion in 'Scripting' started by FeastSC2, Aug 18, 2017.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I want to set the current event that's currently null to a new keyboard event.

    Code (CSharp):
    1. Event.current = Event.KeyboardEvent("v");
    2. Debug.Log(Event.KeyboardEvent("v")); // gives "v" as intended
    3. Debug.Log(Event.current); // gives a null
    How can I do set the current event to a new one?
     
  2. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Hate to be that guy... but why do you want to do this? I'm not sure you could rely on setting it if Unity itself is able to set it as well.
     
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,533
    Needs to be in the OnGUI() loop.