using System; using UnityEngine; namespace ICODES.STUDIO.WWebView { public static class InputTools { public static bool GetMouseState(ref int state, ref int key) { if (InputTools.DidMouseMove()) { state = 0; return true; } for (key = 0; key < 3; key++) { if (InputTools.DidMouseClick(ref state, ref key)) { return true; } } if (InputTools.DidMouseWheel(ref key)) { state = 3; return true; } return false; } public static bool DidMouseClick(ref int state, ref int key) { if (Input.GetMouseButtonDown(key)) { state = 1; return true; } if (Input.GetMouseButtonUp(key)) { state = 2; return true; } return false; } public static bool DidMouseMove() { return Input.GetAxis("Mouse X") != 0f || Input.GetAxis("Mouse Y") != 0f; } public static bool DidMouseWheel(ref int key) { if (Input.GetAxis("Mouse ScrollWheel") > 0f) { key = 1; return true; } if (Input.GetAxis("Mouse ScrollWheel") < 0f) { key = -1; return true; } return false; } private enum Event { MouseMove, MouseDown, MouseUp, MouseWheel } } }