C++RAW #include "UnityPrefix.h" #include "Runtime/IMGUI/IMGUIUtils.h" #include "Runtime/Scripting/ScriptingUtility.h" #include "Runtime/Scripting/ScriptingObjectWithIntPtrField.h" /* Mono defines a bool as either 1 or 2 bytes. On windows a bool on the C++ side needs to be 2 bytes. We use the typemap to map bool's to short's. When using the C++ keyword and you want to export a bool value to mono you have to use a short on the C++ side. */ void PauseEditor (); using namespace std; CSRAW using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Collections; namespace UnityEngine { C++RAW static void CleanupInputEvent(void* inputEvent){ delete (InputEvent*)inputEvent; }; // A UnityGUI event. CSRAW [StructLayout (LayoutKind.Sequential)] CLASS Event CSRAW // *undocumented public Event () { Init (); } THREAD_SAFE CUSTOM private void Init () { InputEvent* newEvent = new InputEvent (); self.SetPtr(newEvent,CleanupInputEvent); newEvent->Init(); } // Copy an event CSRAW public Event (Event other) { if (other == null) throw new ArgumentException ("Event to copy from is null."); InitCopy (other); } // *undocumented CSRAW private Event (IntPtr ptr) { InitPtr (ptr); } // *undocumented CSRAW ~Event () { Cleanup (); } THREAD_SAFE CUSTOM private void Cleanup () { CleanupInputEvent(self.GetPtr()); } THREAD_SAFE CUSTOM private void InitCopy (Event other) { self.SetPtr(new InputEvent (*other), CleanupInputEvent); } THREAD_SAFE CUSTOM private void InitPtr (IntPtr ptr) { self.SetPtr((InputEvent*)ptr, CleanupInputEvent); } CSRAW [System.NonSerialized] [NotRenamed] internal IntPtr m_Ptr; CUSTOM_PROP EventType rawType { return self->type; } // The type of event. CUSTOM_PROP EventType type { return IMGUI::GetEventType (GetGUIState(), *self); } { self->type = value; } CUSTOM EventType GetTypeForControl (int controlID) { return IMGUI::GetEventTypeForControl (GetGUIState(), *self, controlID); } /// Information about the current mouse or touch event, available during On*Event series of callbacks. CONDITIONAL ENABLE_NEW_EVENT_SYSTEM CUSTOM_PROP Touch touch { return self->touch; } // The mouse position. CSRAW public Vector2 mousePosition { get { Vector2 tmp; Internal_GetMousePosition(out tmp); return tmp; } set { Internal_SetMousePosition (value); } } CUSTOM private void Internal_SetMousePosition (Vector2 value) { #if ENABLE_NEW_EVENT_SYSTEM self->touch.pos = value; #else self->mousePosition = value; #endif } CUSTOM private void Internal_GetMousePosition (out Vector2 value) { #if ENABLE_NEW_EVENT_SYSTEM *value = self->touch.pos; #else *value = self->mousePosition; #endif } // The relative movement of the mouse compared to last event. CSRAW public Vector2 delta { get { Vector2 tmp; Internal_GetMouseDelta(out tmp); return tmp; } set { Internal_SetMouseDelta (value); } } CUSTOM private void Internal_SetMouseDelta (Vector2 value) { #if ENABLE_NEW_EVENT_SYSTEM self->touch.deltaPos = value; #else self->delta = value; #endif } CUSTOM private void Internal_GetMouseDelta (out Vector2 value) { #if ENABLE_NEW_EVENT_SYSTEM *value = self->touch.deltaPos; #else *value = self->delta; #endif } OBSOLETE error Use HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); CSRAW public Ray mouseRay { get { return new Ray (Vector3.up, Vector3.up); } set { }} // Which mouse button was pressed. CUSTOM_PROP int button { return self->button; } { self->button = value; } // Which modifier keys are held down. CUSTOM_PROP EventModifiers modifiers { return self->modifiers; } { self->modifiers = value; } // *undocumented* CUSTOM_PROP float pressure { return self->pressure; } { self->pressure = value; } // How many consecutive mouse clicks have we received. // Detects consecutive clicks and prints them. // CUSTOM_PROP int clickCount { return self->clickCount; } { self->clickCount = value; } // The character typed. // Detects characters pressed and prints them. // CUSTOM_PROP char character { return self->character; } { self->character = value; } // The name of an ExecuteCommand or ValidateCommand Event CUSTOM_PROP string commandName { char* commandString = self->commandString; return scripting_string_new(commandString == NULL ? "" : commandString); } { #if ENABLE_MONO char* oldPtr = reinterpret_cast(self->commandString); delete[] oldPtr; char *str = mono_string_to_utf8 (value.str); self->commandString = new char[strlen (str) + 1]; strcpy (self->commandString, str); #endif } // The raw key code for keyboard events. CUSTOM_PROP KeyCode keyCode { return self->keycode; } { self->keycode = value; } // Is Shift held down? (RO) CSRAW public bool shift { get { return (modifiers & EventModifiers.Shift) != 0; } set { if (!value) modifiers &= ~EventModifiers.Shift; else modifiers |= EventModifiers.Shift; } } // Is Control key held down? (RO) CSRAW public bool control { get { return (modifiers & EventModifiers.Control) != 0; } set { if (!value) modifiers &= ~EventModifiers.Control; else modifiers |= EventModifiers.Control; } } // Is Alt/Option key held down? (RO) CSRAW public bool alt { get { return (modifiers & EventModifiers.Alt) != 0; } set { if (!value) modifiers &= ~EventModifiers.Alt; else modifiers |= EventModifiers.Alt; } } // Is Command/Windows key held down? (RO) CSRAW public bool command { get { return (modifiers & EventModifiers.Command) != 0; } set { if (!value) modifiers &= ~EventModifiers.Command; else modifiers |= EventModifiers.Command; } } // Is Caps Lock on? (RO) CSRAW public bool capsLock { get { return (modifiers & EventModifiers.CapsLock) != 0; } set { if (!value) modifiers &= ~EventModifiers.CapsLock; else modifiers |= EventModifiers.CapsLock; } } // Is the current keypress on the numeric keyboard? (RO) CSRAW public bool numeric { get { return (modifiers & EventModifiers.Numeric) != 0; } set { if (!value) modifiers &= ~EventModifiers.Shift; else modifiers |= EventModifiers.Shift; } } // Is the current keypress a function key? (RO) CSRAW public bool functionKey { get { return (modifiers & EventModifiers.FunctionKey) != 0; } } // The current event that's being processed right now. // TODO: set this to null outside the event loop. // CSRAW public static Event current { get { // return null if Event.current is queried outside OnGUI // Only in editor because of backwards compat. #if UNITY_EDITOR if (GUIUtility.Internal_GetGUIDepth () > 0) return s_Current; else return null; #else return s_Current; #endif } set { if (value != null) s_Current = value; else s_Current = s_MasterEvent; Internal_SetNativeEvent (s_Current.m_Ptr); } } CSRAW static Event s_Current; CSRAW static Event s_MasterEvent; CUSTOM static private void Internal_SetNativeEvent (IntPtr ptr) { GetGUIState().Internal_SetManagedEvent (ptr); } CSRAW static private void Internal_MakeMasterEventCurrent () { if (s_MasterEvent == null) s_MasterEvent = new Event (); s_Current = s_MasterEvent; Internal_SetNativeEvent (s_MasterEvent.m_Ptr); } // Use this event. CUSTOM void Use () { self->Use(); } // Is this event a keyboard event? (RO) CSRAW public bool isKey { get { EventType t = type; return t == EventType.KeyDown || t == EventType.KeyUp; } } // Is this event a mouse event? (RO) CSRAW public bool isMouse { get { EventType t = type; return t == EventType.MouseMove || t == EventType.MouseDown || t == EventType.MouseUp || t == EventType.MouseDrag; } } // Create a keyboard event. CSRAW public static Event KeyboardEvent (string key) { Event evt = new Event (); evt.type = EventType.KeyDown; // Can't use string.IsNullOrEmpty because it's not supported in NET 1.1 if (key == null || key == String.Empty) return evt; int startIdx = 0; bool found = false; do { found = true; if (startIdx >= key.Length) { found = false; break; } switch (key[startIdx]) { case '&': // Alt evt.modifiers |= EventModifiers.Alt; startIdx++; break; case '^': // Ctrl evt.modifiers |= EventModifiers.Control; startIdx++; break; case '%': evt.modifiers |= EventModifiers.Command; startIdx++; break; case '#': evt.modifiers |= EventModifiers.Shift; startIdx++; break; default: found = false; break; } } while (found); string subStr = key.Substring (startIdx, key.Length - startIdx).ToLower(); switch (subStr) { case "[0]": evt.character = '0'; evt.keyCode = KeyCode.Keypad0; break; case "[1]": evt.character = '1'; evt.keyCode = KeyCode.Keypad1; break; case "[2]": evt.character = '2'; evt.keyCode = KeyCode.Keypad2; break; case "[3]": evt.character = '3'; evt.keyCode = KeyCode.Keypad3; break; case "[4]": evt.character = '4'; evt.keyCode = KeyCode.Keypad4; break; case "[5]": evt.character = '5'; evt.keyCode = KeyCode.Keypad5; break; case "[6]": evt.character = '6'; evt.keyCode = KeyCode.Keypad6; break; case "[7]": evt.character = '7'; evt.keyCode = KeyCode.Keypad7; break; case "[8]": evt.character = '8'; evt.keyCode = KeyCode.Keypad8; break; case "[9]": evt.character = '9'; evt.keyCode = KeyCode.Keypad9; break; case "[.]": evt.character = '.'; evt.keyCode = KeyCode.KeypadPeriod; break; case "[/]": evt.character = '/'; evt.keyCode = KeyCode.KeypadDivide; break; case "[-]": evt.character = '-'; evt.keyCode = KeyCode.KeypadMinus; break; case "[+]": evt.character = '+'; evt.keyCode = KeyCode.KeypadPlus; break; case "[=]": evt.character = '='; evt.keyCode = KeyCode.KeypadEquals; break; case "[equals]": evt.character = '='; evt.keyCode = KeyCode.KeypadEquals; break; case "[enter]": evt.character = '\n'; evt.keyCode = KeyCode.KeypadEnter; break; case "up": /*evt.character = (char)63232; */evt.keyCode = KeyCode.UpArrow; evt.modifiers |= EventModifiers.FunctionKey; break; case "down": /*evt.character = (char)63233; */evt.keyCode = KeyCode.DownArrow; evt.modifiers |= EventModifiers.FunctionKey; break; case "left": /*evt.character = (char)63234; */evt.keyCode = KeyCode.LeftArrow; evt.modifiers |= EventModifiers.FunctionKey; break; case "right": /*evt.character = (char)63235; */evt.keyCode = KeyCode.RightArrow; evt.modifiers |= EventModifiers.FunctionKey; break; case "insert": evt.keyCode = KeyCode.Insert; evt.modifiers |= EventModifiers.FunctionKey; break; case "home": /*evt.character = (char)63273; */evt.keyCode = KeyCode.Home; evt.modifiers |= EventModifiers.FunctionKey; break; case "end": /*evt.character = (char)63275; */evt.keyCode = KeyCode.End; evt.modifiers |= EventModifiers.FunctionKey; break; case "pgup": /*evt.character = (char)63276; */evt.keyCode = KeyCode.PageDown; evt.modifiers |= EventModifiers.FunctionKey; break; case "page up": /*evt.character = (char)63276; */evt.keyCode = KeyCode.PageUp; evt.modifiers |= EventModifiers.FunctionKey; break; case "pgdown": /*evt.character = (char)63277; */evt.keyCode = KeyCode.PageUp; evt.modifiers |= EventModifiers.FunctionKey; break; case "page down": /*evt.character = (char)63277; */evt.keyCode = KeyCode.PageDown; evt.modifiers |= EventModifiers.FunctionKey; break; case "backspace": /*evt.character = (char)127; */evt.keyCode = KeyCode.Backspace; evt.modifiers |= EventModifiers.FunctionKey; break; case "delete": /*evt.character = (char)63272; */evt.keyCode = KeyCode.Delete; evt.modifiers |= EventModifiers.FunctionKey; break; case "tab": /*evt.character = (char)9; */evt.keyCode = KeyCode.Tab; break; case "f1": /*evt.character = (char)63236; */evt.keyCode = KeyCode.F1; evt.modifiers |= EventModifiers.FunctionKey; break; case "f2": /*evt.character = (char)63237; */evt.keyCode = KeyCode.F2; evt.modifiers |= EventModifiers.FunctionKey; break; case "f3": /*evt.character = (char)63238; */evt.keyCode = KeyCode.F3; evt.modifiers |= EventModifiers.FunctionKey; break; case "f4": /*evt.character = (char)63239; */evt.keyCode = KeyCode.F4; evt.modifiers |= EventModifiers.FunctionKey; break; case "f5": /*evt.character = (char)63240; */evt.keyCode = KeyCode.F5; evt.modifiers |= EventModifiers.FunctionKey; break; case "f6": /*evt.character = (char)63241; */evt.keyCode = KeyCode.F6; evt.modifiers |= EventModifiers.FunctionKey; break; case "f7": /*evt.character = (char)63242; */evt.keyCode = KeyCode.F7; evt.modifiers |= EventModifiers.FunctionKey; break; case "f8": /*evt.character = (char)63243; */evt.keyCode = KeyCode.F8; evt.modifiers |= EventModifiers.FunctionKey; break; case "f9": /*evt.character = (char)63244; */evt.keyCode = KeyCode.F9; evt.modifiers |= EventModifiers.FunctionKey; break; case "f10": /*evt.character = (char)63245; */evt.keyCode = KeyCode.F10; evt.modifiers |= EventModifiers.FunctionKey; break; case "f11": /*evt.character = (char)63246; */evt.keyCode = KeyCode.F11; evt.modifiers |= EventModifiers.FunctionKey; break; case "f12": /*evt.character = (char)63247; */evt.keyCode = KeyCode.F12; evt.modifiers |= EventModifiers.FunctionKey; break; case "f13": /*evt.character = (char)63248; */evt.keyCode = KeyCode.F13; evt.modifiers |= EventModifiers.FunctionKey; break; case "f14": /*evt.character = (char)63249; */evt.keyCode = KeyCode.F14; evt.modifiers |= EventModifiers.FunctionKey; break; case "f15": /*evt.character = (char)63250; */evt.keyCode = KeyCode.F15; evt.modifiers |= EventModifiers.FunctionKey; break; case "[esc]": evt.keyCode = KeyCode.Escape; break; case "return": evt.character = '\n'; evt.keyCode = KeyCode.Return; evt.modifiers &= ~EventModifiers.FunctionKey; break; case "space": evt.keyCode = KeyCode.Space; evt.character = ' '; evt.modifiers &= ~EventModifiers.FunctionKey; break; default: if (subStr.Length != 1) { // soren: try this first try { evt.keyCode = (KeyCode)Enum.Parse(typeof(KeyCode), subStr, true); } catch (ArgumentException) { Debug.LogError (UnityString.Format ("Unable to find key name that matches '{0}'", subStr)); } } else { evt.character = subStr.ToLower()[0]; evt.keyCode = (KeyCode)evt.character; if ((int)evt.modifiers != 0) evt.character = (char)0; } break; } return evt; } // Calculate the hash code CSRAW public override int GetHashCode( ) { int hc = 1; if (isKey) hc = (ushort)keyCode; if (isMouse) hc = mousePosition.GetHashCode (); hc = hc*37 | (int)modifiers; // Debug.Log (hc + " GetHashCode of " + ToString()); return hc; } CSRAW public override bool Equals (object obj) { if (obj == null) return false; if (Object.ReferenceEquals (this, obj)) return true; if (obj.GetType () != GetType()) return false; Event rhs = (Event)obj; if (type != rhs.type || modifiers != rhs.modifiers) return false; if (isKey) return keyCode == rhs.keyCode && modifiers == rhs.modifiers; if (isMouse) return mousePosition == rhs.mousePosition; return false; } CSRAW public override string ToString( ) { if (isKey) { if ((int)character == 0) return UnityString.Format ("Event:{0} Character:\\0 Modifiers:{1} KeyCode:{2}", type, modifiers, keyCode); else { return UnityString.Format ("Event:" +type + " Character:" + (int)(character) + " Modifiers:" + modifiers + " KeyCode:" + keyCode); } } if (isMouse) return UnityString.Format ("Event: {0} Position: {1} Modifiers: {2}", type, mousePosition, modifiers); if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand) return UnityString.Format ("Event: {0} \"{1}\"", type, commandName); return "" + type; } C++RAW END // Key codes returned by Event.keyCode. These map directly to a physical key on the keyboard. ENUM KeyCode // Not assigned (never returned as the result of a keystroke) None = 0, // The backspace key Backspace = 8, // The forward delete key Delete = 127, // The tab key Tab = 9, // The Clear key Clear = 12, // Return key Return = 13, // Pause on PC machines Pause = 19, // Escape key Escape = 27, // Space key Space = 32, // Numeric keypad 0 Keypad0 = 256, // Numeric keypad 1 Keypad1 = 257, // Numeric keypad 2 Keypad2 = 258, // Numeric keypad 3 Keypad3 = 259, // Numeric keypad 4 Keypad4 = 260, // Numeric keypad 5 Keypad5 = 261, // Numeric keypad 6 Keypad6 = 262, // Numeric keypad 7 Keypad7 = 263, // Numeric keypad 8 Keypad8 = 264, // Numeric keypad 9 Keypad9 = 265, // Numeric keypad '.' KeypadPeriod = 266, // Numeric keypad '/' KeypadDivide = 267, // Numeric keypad '*' KeypadMultiply = 268, // Numeric keypad '-' KeypadMinus = 269, // Numeric keypad '+' KeypadPlus = 270, // Numeric keypad enter KeypadEnter = 271, // Numeric keypad '=' KeypadEquals = 272, // Up arrow key UpArrow = 273, // Down arrow key DownArrow = 274, // Right arrow key RightArrow = 275, // Left arrow key LeftArrow = 276, // Insert key key Insert = 277, // Home key Home = 278, // End key End = 279, // Page up PageUp = 280, // Page down PageDown = 281, // F1 function key F1 = 282, // F2 function key F2 = 283, // F3 function key F3 = 284, // F4 function key F4 = 285, // F5 function key F5 = 286, // F6 function key F6 = 287, // F7 function key F7 = 288, // F8 function key F8 = 289, // F9 function key F9 = 290, // F10 function key F10 = 291, // F11 function key F11 = 292, // F12 function key F12 = 293, // F13 function key F13 = 294, // F14 function key F14 = 295, // F15 function key F15 = 296, // The '0' key on the top of the alphanumeric keyboard. Alpha0 = 48, // The '1' key on the top of the alphanumeric keyboard. Alpha1 = 49, // The '2' key on the top of the alphanumeric keyboard. Alpha2 = 50, // The '3' key on the top of the alphanumeric keyboard. Alpha3 = 51, // The '4' key on the top of the alphanumeric keyboard. Alpha4 = 52, // The '5' key on the top of the alphanumeric keyboard. Alpha5 = 53, // The '6' key on the top of the alphanumeric keyboard. Alpha6 = 54, // The '7' key on the top of the alphanumeric keyboard. Alpha7 = 55, // The '8' key on the top of the alphanumeric keyboard. Alpha8 = 56, // The '9' key on the top of the alphanumeric keyboard. Alpha9 = 57, // Exclamation mark key '!' Exclaim = 33, // Double quote key '"' DoubleQuote = 34, // Hash key '#' Hash = 35, // Dollar sign key '$' Dollar = 36, // Ampersand key '&' Ampersand = 38, // Quote key ' Quote = 39, // Left Parenthesis key '(' LeftParen = 40, // Right Parenthesis key ')' RightParen = 41, // Asterisk key '*' Asterisk = 42, // Plus key '+' Plus = 43, // Comma ',' key Comma = 44, // Minus '-' key Minus = 45, // Period '.' key Period = 46, // Slash '/' key Slash = 47, // Colon ':' key Colon = 58, // Semicolon ';' key Semicolon = 59, // Less than '<' key Less = 60, // Equals '=' key Equals = 61, // Greater than '>' key Greater = 62, // Question mark '?' key Question = 63, // At key '@' At = 64, // Left square bracket key '[' LeftBracket = 91, // Backslash key '\' Backslash = 92, // Right square bracket key ']' RightBracket = 93, // Caret key '^' Caret = 94, // Underscore '_' key Underscore = 95, // Back quote key '`' BackQuote = 96, // 'a' key A = 97, // 'b' key B = 98, // 'c' key C = 99, // 'd' key D = 100, // 'e' key E = 101, // 'f' key F = 102, // 'g' key G = 103, // 'h' key H = 104, // 'i' key I = 105, // 'j' key J = 106, // 'k' key K = 107, // 'l' key L = 108, // 'm' key M = 109, // 'n' key N = 110, // 'o' key O = 111, // 'p' key P = 112, // 'q' key Q = 113, // 'r' key R = 114, // 's' key S = 115, // 't' key T = 116, // 'u' key U = 117, // 'v' key V = 118, // 'w' key W = 119, // 'x' key X = 120, // 'y' key Y = 121, // 'z' key Z = 122, // Numlock key Numlock = 300, // Capslock key CapsLock = 301, // Scroll lock key ScrollLock = 302, // Right shift key RightShift = 303, // Left shift key LeftShift = 304, // Right Control key RightControl = 305, // Left Control key LeftControl = 306, // Right Alt key RightAlt = 307, // Left Alt key LeftAlt = 308, // Left Command key LeftCommand = 310, // Left Command key LeftApple = 310, // Left Windows key LeftWindows = 311, // Right Command key RightCommand = 309, // Right Command key RightApple = 309, // Right Windows key RightWindows = 312, // Alt Gr key AltGr = 313, // Help key Help = 315, // Print key Print = 316, // Sys Req key SysReq = 317, // Break key Break = 318, // Menu key Menu = 319, // First (primary) mouse button Mouse0 = 323, // Second (secondary) mouse button Mouse1 = 324, // Third mouse button Mouse2 = 325, // Fourth mouse button Mouse3 = 326, // Fifth mouse button Mouse4 = 327, // Sixth mouse button Mouse5 = 328, // Seventh mouse button Mouse6 = 329, // Button 0 on any joystick JoystickButton0 = 330, // Button 1 on any joystick JoystickButton1 = 331, // Button 2 on any joystick JoystickButton2 = 332, // Button 3 on any joystick JoystickButton3 = 333, // Button 4 on any joystick JoystickButton4 = 334, // Button 5 on any joystick JoystickButton5 = 335, // Button 6 on any joystick JoystickButton6 = 336, // Button 7 on any joystick JoystickButton7 = 337, // Button 8 on any joystick JoystickButton8 = 338, // Button 9 on any joystick JoystickButton9 = 339, // Button 10 on any joystick JoystickButton10 = 340, // Button 11 on any joystick JoystickButton11 = 341, // Button 12 on any joystick JoystickButton12 = 342, // Button 13 on any joystick JoystickButton13 = 343, // Button 14 on any joystick JoystickButton14 = 344, // Button 15 on any joystick JoystickButton15 = 345, // Button 16 on any joystick JoystickButton16 = 346, // Button 17 on any joystick JoystickButton17 = 347, // Button 18 on any joystick JoystickButton18 = 348, // Button 19 on any joystick JoystickButton19 = 349, // Button 0 on first joystick Joystick1Button0 = 350, // Button 1 on first joystick Joystick1Button1 = 351, // Button 2 on first joystick Joystick1Button2 = 352, // Button 3 on first joystick Joystick1Button3 = 353, // Button 4 on first joystick Joystick1Button4 = 354, // Button 5 on first joystick Joystick1Button5 = 355, // Button 6 on first joystick Joystick1Button6 = 356, // Button 7 on first joystick Joystick1Button7 = 357, // Button 8 on first joystick Joystick1Button8 = 358, // Button 9 on first joystick Joystick1Button9 = 359, // Button 10 on first joystick Joystick1Button10 = 360, // Button 11 on first joystick Joystick1Button11 = 361, // Button 12 on first joystick Joystick1Button12 = 362, // Button 13 on first joystick Joystick1Button13 = 363, // Button 14 on first joystick Joystick1Button14 = 364, // Button 15 on first joystick Joystick1Button15 = 365, // Button 16 on first joystick Joystick1Button16 = 366, // Button 17 on first joystick Joystick1Button17 = 367, // Button 18 on first joystick Joystick1Button18 = 368, // Button 19 on first joystick Joystick1Button19 = 369, // Button 0 on second joystick Joystick2Button0 = 370, // Button 1 on second joystick Joystick2Button1 = 371, // Button 2 on second joystick Joystick2Button2 = 372, // Button 3 on second joystick Joystick2Button3 = 373, // Button 4 on second joystick Joystick2Button4 = 374, // Button 5 on second joystick Joystick2Button5 = 375, // Button 6 on second joystick Joystick2Button6 = 376, // Button 7 on second joystick Joystick2Button7 = 377, // Button 8 on second joystick Joystick2Button8 = 378, // Button 9 on second joystick Joystick2Button9 = 379, // Button 10 on second joystick Joystick2Button10 = 380, // Button 11 on second joystick Joystick2Button11 = 381, // Button 12 on second joystick Joystick2Button12 = 382, // Button 13 on second joystick Joystick2Button13 = 383, // Button 14 on second joystick Joystick2Button14 = 384, // Button 15 on second joystick Joystick2Button15 = 385, // Button 16 on second joystick Joystick2Button16 = 386, // Button 17 on second joystick Joystick2Button17 = 387, // Button 18 on second joystick Joystick2Button18 = 388, // Button 19 on second joystick Joystick2Button19 = 389, // Button 0 on third joystick Joystick3Button0 = 390, // Button 1 on third joystick Joystick3Button1 = 391, // Button 2 on third joystick Joystick3Button2 = 392, // Button 3 on third joystick Joystick3Button3 = 393, // Button 4 on third joystick Joystick3Button4 = 394, // Button 5 on third joystick Joystick3Button5 = 395, // Button 6 on third joystick Joystick3Button6 = 396, // Button 7 on third joystick Joystick3Button7 = 397, // Button 8 on third joystick Joystick3Button8 = 398, // Button 9 on third joystick Joystick3Button9 = 399, // Button 10 on third joystick Joystick3Button10 = 400, // Button 11 on third joystick Joystick3Button11 = 401, // Button 12 on third joystick Joystick3Button12 = 402, // Button 13 on third joystick Joystick3Button13 = 403, // Button 14 on third joystick Joystick3Button14 = 404, // Button 15 on third joystick Joystick3Button15 = 405, // Button 16 on third joystick Joystick3Button16 = 406, // Button 17 on third joystick Joystick3Button17 = 407, // Button 18 on third joystick Joystick3Button18 = 408, // Button 19 on third joystick Joystick3Button19 = 409, // Button 0 on forth joystick Joystick4Button0 = 410, // Button 1 on forth joystick Joystick4Button1 = 411, // Button 2 on forth joystick Joystick4Button2 = 412, // Button 3 on forth joystick Joystick4Button3 = 413, // Button 4 on forth joystick Joystick4Button4 = 414, // Button 5 on forth joystick Joystick4Button5 = 415, // Button 6 on forth joystick Joystick4Button6 = 416, // Button 7 on forth joystick Joystick4Button7 = 417, // Button 8 on forth joystick Joystick4Button8 = 418, // Button 9 on forth joystick Joystick4Button9 = 419, // Button 10 on forth joystick Joystick4Button10 = 420, // Button 11 on forth joystick Joystick4Button11 = 421, // Button 12 on forth joystick Joystick4Button12 = 422, // Button 13 on forth joystick Joystick4Button13 = 423, // Button 14 on forth joystick Joystick4Button14 = 424, // Button 15 on forth joystick Joystick4Button15 = 425, // Button 16 on forth joystick Joystick4Button16 = 426, // Button 17 on forth joystick Joystick4Button17 = 427, // Button 18 on forth joystick Joystick4Button18 = 428, // Button 19 on forth joystick Joystick4Button19 = 429, // We could expose all 10 joysticks here, but I think that a user would rarely want to explicitly // specify a fifth or higher joystick (and they still can using the string version of Input.KeyDown). // Four joysticks, however, are a common setup (especially on consoles), and we've had a bug report // for only exposing three, so I added a forth. END // Types of UnityGUI input and processing events. ENUM EventType // Mouse button was pressed. MouseDown = 0, // Mouse button was released. MouseUp = 1, // Mouse was moved (editor views only). MouseMove = 2, // Mouse was dragged. MouseDrag = 3, // A keyboard key was pressed. KeyDown = 4, // A keyboard key was released. KeyUp = 5, // The scroll wheel was moved. ScrollWheel = 6, // A repaint event. One is sent every frame. Repaint = 7, // A layout event. Layout = 8, // Editor only: drag & drop operation updated. DragUpdated = 9, // Editor only: drag & drop operation performed. DragPerform = 10, // Editor only: drag & drop operation exited. DragExited = 15, // [[Event]] should be ignored. Ignore = 11, // Already processed event. Used = 12, // Validates a special command (e.g. copy & paste) ValidateCommand = 13, // Execute a special command (eg. copy & paste) ExecuteCommand = 14, // User has right-clicked (or control-clicked on the mac). ContextClick = 16, OBSOLETE planned Please use EventType.MouseDown (with a capital M) mouseDown = 0, OBSOLETE planned Please use EventType.MouseUp (with a capital M) mouseUp = 1, OBSOLETE planned Please use EventType.MouseMove (with a capital M) mouseMove = 2, OBSOLETE planned Please use EventType.MouseDrag (with a capital M) mouseDrag = 3, OBSOLETE planned Please use EventType.KeyDown (with a capital K) keyDown = 4, OBSOLETE planned Please use EventType.KeyUp (with a capital K) keyUp = 5, OBSOLETE planned Please use EventType.ScrollWheel (with a capital S) scrollWheel = 6, OBSOLETE planned Please use EventType.Repaint (with a capital R) repaint = 7, OBSOLETE planned Please use EventType.Layout (with a capital L) layout = 8, OBSOLETE planned Please use EventType.DragUpdated (with a capital D) dragUpdated = 9, OBSOLETE planned Please use EventType.DragPerform (with a capital D) dragPerform = 10, OBSOLETE planned Please use EventType.Ignore (with a capital I) ignore = 11, OBSOLETE planned Please use EventType.Used (with a capital U) used = 12 END // Types of modifier key that can be active during a keystroke event. CSRAW [Flags] ENUM EventModifiers // Shift key Shift = 1, // Control key Control = 2, // Alt key Alt = 4, // Command key (Mac) Command = 8, // Num lock key Numeric = 16, // Caps lock key CapsLock = 32, // Function key FunctionKey = 64 END CSRAW }