Event.current not defined [SOLVED]

I seem to be having a bit of a stupid issue most likely to missing some namespace call. When i try to use Event.current I get "Error CS0117 ‘Event’ does not contain a definition for ‘current’ Custom Editors.CSharp.Editor " though current is suposedly a static method according to documentation.Can anyone give me some insight on this or just tell the stupid mistake I did somewhere?

Code of the file: (line 20 and 23 contain the method calls)

using UnityEngine;


public class Popuptest
{
  static int popupListHash = "PopupList".GetHashCode();

  public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, GUIContent[] listContent,
  GUIStyle listStyle)
  {
  return List(position, ref showList, ref listEntry, buttonContent, listContent, "button", "box", listStyle);
  }

  public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, GUIContent[] listContent,
  GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle)
  {
  int controlID = GUIUtility.GetControlID(popupListHash, FocusType.Passive);
  bool done = false;
  switch (Event.current.GetTypeForControl(controlID))
  {
  case EventType.mouseDown:
  if (position.Contains(Event.current.mousePosition))
  {
  GUIUtility.hotControl = controlID;
  showList = true;
  }
  break;
  case EventType.mouseUp:
  if (showList)
  {
  done = true;
  }
  break;
  }

  GUI.Label(position, buttonContent, buttonStyle);
  if (showList)
  {
  Rect listRect = new Rect(position.x, position.y, position.width, listStyle.CalcHeight(listContent[0], 1.0f) * listContent.Length);
  GUI.Box(listRect, "", boxStyle);
  listEntry = GUI.SelectionGrid(listRect, listEntry, listContent, 1, listStyle);
  }
  if (done)
  {
  showList = false;
  }
  return done;
  }
}

[SOLVED] Aparently there was a custom class on that project also called Event

1 Like

Really glad you came back and left the solution, saved me - Mucho graciases!

7 years later…just resolved my problem :slight_smile: