// Update is called once per frame void Update() { UnityEngine.EventSystems.EventSystem eventSystem = UnityEngine.EventSystems.EventSystem.current; #if UNITY_ANDROID && !UNITY_EDITOR PreviousFrameTouch = ThisFrameTouch; PreviousTouchPosition = TouchPosition; if (Input.touchCount > 0) { if (!eventSystem.IsPointerOverGameObject()) { if (!_inputUILock) { TouchPosition = Input.touches[0].position; ThisFrameTouch = true; } } else { _inputUILock = true; } } else { ThisFrameTouch = false; _inputUILock = false; } #else PreviousFrameTouch = ThisFrameTouch; PreviousTouchPosition = TouchPosition; if (Input.GetMouseButton(0)) { if (!eventSystem.IsPointerOverGameObject()) { if (!_inputUILock) { TouchPosition = Input.mousePosition; ThisFrameTouch = true; } } else { _inputUILock = true; } } else { _inputUILock = false; ThisFrameTouch = false; } #endif }
static public int IsPointerOverGameObject(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); var ret = self.IsPointerOverGameObject(); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); var ret = self.IsPointerOverGameObject(a1); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function IsPointerOverGameObject to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static int IsPointerOverGameObject(IntPtr L) { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.EventSystems.EventSystem obj = (UnityEngine.EventSystems.EventSystem)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UnityEngine.EventSystems.EventSystem"); bool o = obj.IsPointerOverGameObject(); LuaScriptMgr.Push(L, o); return(1); } else if (count == 2) { UnityEngine.EventSystems.EventSystem obj = (UnityEngine.EventSystems.EventSystem)LuaScriptMgr.GetUnityObjectSelf(L, 1, "UnityEngine.EventSystems.EventSystem"); int arg0 = (int)LuaScriptMgr.GetNumber(L, 2); bool o = obj.IsPointerOverGameObject(arg0); LuaScriptMgr.Push(L, o); return(1); } else { LuaDLL.luaL_error(L, "invalid arguments to method: UnityEngine.EventSystems.EventSystem.IsPointerOverGameObject"); } return(0); }
static public int IsPointerOverGameObject(IntPtr l) { try{ int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); System.Boolean ret = self.IsPointerOverGameObject(); pushValue(l, ret); return(1); } else if (argc == 2) { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); System.Boolean ret = self.IsPointerOverGameObject(a1); pushValue(l, ret); return(1); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int IsPointerOverGameObject(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.EventSystems.EventSystem.Register"); #endif try { int count = LuaDLL.lua_gettop(L); if (count == 1) { UnityEngine.EventSystems.EventSystem obj = (UnityEngine.EventSystems.EventSystem)ToLua.CheckObject <UnityEngine.EventSystems.EventSystem>(L, 1); bool o = obj.IsPointerOverGameObject(); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2) { UnityEngine.EventSystems.EventSystem obj = (UnityEngine.EventSystems.EventSystem)ToLua.CheckObject <UnityEngine.EventSystems.EventSystem>(L, 1); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); bool o = obj.IsPointerOverGameObject(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.EventSystems.EventSystem.IsPointerOverGameObject")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Update is called once per frame void Update() { var horizontal = Camera.main.transform.right; var vertical = Vector3.up; if (Input.GetMouseButton(0) && !eventSystem.IsPointerOverGameObject()) { _controlling.transform.RotateAround(Vector3.zero, horizontal, 3 * Input.GetAxis("Mouse Y")); _controlling.transform.RotateAround(Vector3.zero, vertical, -3 * Input.GetAxis("Mouse X")); } if (autoRotate) { volume.transform.Rotate(rotateSpeed * Time.deltaTime * new Vector3(0, -1, 0), Space.World); } if (autoRotateCamera) { camera.transform.RotateAround(volume.transform.position, Vector3.up, cameraRotateSpeed * Time.deltaTime); } if (Input.GetMouseButton(1)) { var nearest = volume.transform.position + (camera.transform.position - volume.transform.position).normalized * 0.5f; var dir = volume.transform.position - camera.transform.position; var currDistance = dir.magnitude; camera.transform.position = camera.transform.position + dir * Mathf.Min(currDistance - 0.2f, 5.0f * Time.deltaTime * Input.GetAxis("Mouse Y")); } }
static int IsPointerOverGameObject(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 1 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.EventSystems.EventSystem))) { UnityEngine.EventSystems.EventSystem obj = (UnityEngine.EventSystems.EventSystem)ToLua.ToObject(L, 1); bool o = obj.IsPointerOverGameObject(); LuaDLL.lua_pushboolean(L, o); return(1); } else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.EventSystems.EventSystem), typeof(int))) { UnityEngine.EventSystems.EventSystem obj = (UnityEngine.EventSystems.EventSystem)ToLua.ToObject(L, 1); int arg0 = (int)LuaDLL.lua_tonumber(L, 2); bool o = obj.IsPointerOverGameObject(arg0); LuaDLL.lua_pushboolean(L, o); return(1); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.EventSystems.EventSystem.IsPointerOverGameObject")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
void OnMouseUp() { //over a UI element if (_eventSystem.IsPointerOverGameObject()) { return; } //A tool is selected if (Tools.currentTool != null && Tools.currentTool.getName() != "Inspect") { if (Tools.currentTool.getName().Equals("Elevator")) { tower.buildElevator(); } else { tower.build(wVal, hVal); } } }
private bool ClickedOnUI() { UnityEngine.EventSystems.EventSystem ct = UnityEngine.EventSystems.EventSystem.current; if (!ct.IsPointerOverGameObject()) { return(false); } return(true); }
bool ClickOnGUI(Vector3 mousePos) { UnityEngine.EventSystems.EventSystem ct = UnityEngine.EventSystems.EventSystem.current; if (ct.IsPointerOverGameObject()) { return(true); } return(false); }
static public int IsPointerOverGameObject(IntPtr l) { try { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); var ret = self.IsPointerOverGameObject(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int IsPointerOverGameObject(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 1) { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); var ret = self.IsPointerOverGameObject(); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 2) { UnityEngine.EventSystems.EventSystem self = (UnityEngine.EventSystems.EventSystem)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); var ret = self.IsPointerOverGameObject(a1); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function IsPointerOverGameObject to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
public void Highlight() { if (childRenderers != null && !eventSystem.IsPointerOverGameObject()) { childColors = new Queue <Color>(); foreach (Renderer r in childRenderers) { if (r.material.HasProperty("_Color")) { childColors.Enqueue(r.material.color); r.material.color = highlightColor; } } } //Send a message to other scripts on object to begin animation SendMessage("StartHighlightAnimation"); }
/// <summary> /// This function checks if the player pressed on a button, so that /// the actions wont pass through the button. /// </summary> /// <returns></returns> bool CheckIfButtonIsPressed() { UnityEngine.EventSystems.EventSystem ct = UnityEngine.EventSystems.EventSystem.current; if (!ct.IsPointerOverGameObject()) { return(false); } if (!ct.currentSelectedGameObject) { return(false); } if (ct.currentSelectedGameObject.GetComponent <Button>() == null) { return(false); } return(true); }
public bool WasJustADamnedButton() { UnityEngine.EventSystems.EventSystem ct = UnityEngine.EventSystems.EventSystem.current; if (!ct.IsPointerOverGameObject()) { return(false); } if (!ct.currentSelectedGameObject) { return(false); } if (ct.currentSelectedGameObject.GetComponent <Button>() == null) { return(false); } return(true); }
public static bool IsMouseOverUI() { UnityEngine.EventSystems.EventSystem es = UnityEngine.EventSystems.EventSystem.current; return(es != null && es.IsPointerOverGameObject()); }
private UnityEngine.Vector2 ProjectPointer(float x, float y) { if (_textureCamera == null) { return(new UnityEngine.Vector2(x, UnityEngine.Screen.height - y)); } else if (_texture != null) { // Project using texture coordinates // First try with Unity GUI RawImage objects UnityEngine.EventSystems.EventSystem eventSystem = UnityEngine.EventSystems.EventSystem.current; if (eventSystem != null && eventSystem.IsPointerOverGameObject()) { UnityEngine.Vector2 pos = new UnityEngine.Vector2(x, y); if (_pointerData == null) { _pointerData = new UnityEngine.EventSystems.PointerEventData(eventSystem) { pointerId = 0, position = pos }; } else { _pointerData.Reset(); } _pointerData.delta = pos - _pointerData.position; _pointerData.position = pos; UnityEngine.RectTransform rect = GetComponent <UnityEngine.RectTransform>(); if (rect != null && UnityEngine.RectTransformUtility.ScreenPointToLocalPointInRectangle( rect, _pointerData.position, _pointerData.pressEventCamera, out pos)) { UnityEngine.Vector2 pivot = new UnityEngine.Vector2( rect.pivot.x * rect.rect.width, rect.pivot.y * rect.rect.height); float texCoordX = (pos.x + pivot.x) / rect.rect.width; float texCoordY = (pos.y + pivot.y) / rect.rect.height; float localX = _texture.width * texCoordX; float localY = _texture.height * (1.0f - texCoordY); return(new UnityEngine.Vector2(localX, localY)); } } // NOTE: A MeshCollider must be attached to the target to obtain valid // texture coordinates, otherwise Hit Testing won't work UnityEngine.Ray ray = UnityEngine.Camera.main.ScreenPointToRay(new UnityEngine.Vector3(x, y, 0)); UnityEngine.RaycastHit hit; if (UnityEngine.Physics.Raycast(ray, out hit)) { if (hit.collider.gameObject == gameObject) { float localX = _texture.width * hit.textureCoord.x; float localY = _texture.height * (1.0f - hit.textureCoord.y); return(new UnityEngine.Vector2(localX, localY)); } } return(new UnityEngine.Vector2(-1, -1)); } return(Vector2.zero); }
/// <summary> /// 国战EventSystem bug Fixed /// </summary> /// <param name="cacheEventSystem"></param> /// <returns></returns> public static bool IsPointerOverGameObject(UnityEngine.EventSystems.EventSystem cacheEventSystem) { bool overTouch = cacheEventSystem.IsPointerOverGameObject(); return(overTouch); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (myEventSystem.IsPointerOverGameObject() == false) { if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject.tag == "Housing") { //do all hit detection for houses in here //Destroy(hit.transform.gameObject); Debug.Log("hit house"); currentHit = "House"; myUIcontroller.openInfo(); currentBuilding = hit.transform.gameObject.GetComponent <BuildingInfoScript>(); text1.text = currentBuilding.textBox1String; text2.text = currentBuilding.textBox2String; text3.text = currentBuilding.textBox3String; text4.text = currentBuilding.textBox4String; text5.text = currentBuilding.textBox5String; text6.text = currentBuilding.textBox6String; //hit.transform.gameObject.SendMessage("changeMesh"); //send the houses info, should be able to access it here in hit foreach (Transform child in hit.transform.gameObject.transform) { Debug.Log("looping children"); if (child.gameObject.tag == "cameraPosition") { Camera.main.transform.position = child.transform.position; Camera.main.transform.LookAt(hit.transform.gameObject.transform.position); Debug.Log("attempted to change position of camera"); } } } if (hit.transform.gameObject.tag == "School") { //do all hit detection for houses in here //Destroy(hit.transform.gameObject); Debug.Log("hit school"); currentHit = "School"; myUIcontroller.openInfo(); currentBuilding = hit.transform.gameObject.GetComponent <BuildingInfoScript>(); text1.text = currentBuilding.textBox1String; text2.text = currentBuilding.textBox2String; text3.text = currentBuilding.textBox3String; text4.text = currentBuilding.textBox4String; text5.text = currentBuilding.textBox5String; text6.text = currentBuilding.textBox6String; //hit.transform.gameObject.SendMessage("changeMesh"); //this code will send the model change message, need this for talking to object hit.transform.gameObject.SendMessage("changeMesh"); //send the houses info, should be able to access it here in hit foreach (Transform child in hit.transform.gameObject.transform) { Debug.Log("looping children"); if (child.gameObject.tag == "cameraPosition") { Camera.main.transform.position = child.transform.position; Camera.main.transform.LookAt(hit.transform.gameObject.transform.position); Debug.Log("attempted to change position of camera"); } } } if (hit.transform.gameObject.tag == "well") { //do all hit detection for houses in here //Destroy(hit.transform.gameObject); Debug.Log("hit well"); currentHit = "Well"; myUIcontroller.openInfo(); currentBuilding = hit.transform.gameObject.GetComponent <BuildingInfoScript>(); //hit.transform.gameObject.SendMessage("changeMesh"); text1.text = currentBuilding.textBox1String; text2.text = currentBuilding.textBox2String; text3.text = currentBuilding.textBox3String; text4.text = currentBuilding.textBox4String; text5.text = currentBuilding.textBox5String; text6.text = currentBuilding.textBox6String; //this code will send the model change message, need this for talking to object hit.transform.gameObject.SendMessage("changeMesh"); //send the houses info, should be able to access it here in hit foreach (Transform child in hit.transform.gameObject.transform) { Debug.Log("looping children"); if (child.gameObject.tag == "cameraPosition") { Camera.main.transform.position = child.transform.position; Camera.main.transform.LookAt(hit.transform.gameObject.transform.position); Debug.Log("attempted to change position of camera"); } } } if (hit.transform.gameObject.tag == "church") { //do all hit detection for houses in here //Destroy(hit.transform.gameObject); Debug.Log("hit church"); currentHit = "Church"; myUIcontroller.openInfo(); currentBuilding = hit.transform.gameObject.GetComponent <BuildingInfoScript>(); //hit.transform.gameObject.SendMessage("changeMesh"); text1.text = currentBuilding.textBox1String; text2.text = currentBuilding.textBox2String; //text3.text = currentBuilding.textBox3String; text4.text = currentBuilding.textBox4String; text5.text = currentBuilding.textBox5String; text6.text = currentBuilding.textBox6String; //this code will send the model change message, need this for talking to object hit.transform.gameObject.SendMessage("changeMesh"); //send the houses info, should be able to access it here in hit foreach (Transform child in hit.transform.gameObject.transform) { Debug.Log("looping children"); if (child.gameObject.tag == "cameraPosition") { Camera.main.transform.position = child.transform.position; Camera.main.transform.LookAt(hit.transform.gameObject.transform.position); Debug.Log("attempted to change position of camera"); } } } } } } if (currentHit == "Church") { if (StaticValuesScript.isFundraisingActive) { text3.text = "Currently Fundraising:" + StaticValuesScript.currentFundraising; } if (!StaticValuesScript.isFundraisingActive) { text3.text = "Not Currently Fundraising:"; } } }
//方法一, 国战EventSystem bug Fixed 使用该方法的另一个重载方法,使用时给该方法传递一个整形参数 // 该参数即使触摸手势的 id // int id = Input.GetTouch(0).fingerId; public static bool IsPointerOverUIObjectOne(UnityEngine.EventSystems.EventSystem cacheEventSystem, int fingerID) { bool overTouch = cacheEventSystem.IsPointerOverGameObject(fingerID); return(overTouch); }
private bool IsCoveredByUI() { // Prevent clicking if covered by UI element UnityEngine.EventSystems.EventSystem es = UnityEngine.EventSystems.EventSystem.current; return(es != null && es.IsPointerOverGameObject()); }
// Update is called once per frame void Update() { bool touchLastFrame = touchInputThisFrame; touchInputThisFrame = Input.touchCount > 0; if (touchInputThisFrame) { if (!touchLastFrame && cursorRend.enabled) { cursorRend.enabled = false; } } else if (touchLastFrame) { mousePosOnTouchEnd = Input.mousePosition; } else if (!cursorRend.enabled && Vector3.SqrMagnitude(mousePosOnTouchEnd - Input.mousePosition) > 0) { cursorRend.enabled = true; } bool overUI = false; if (eventSys != null) { overUI = eventSys.IsPointerOverGameObject(); } if (zoomingToPosition) { zoomToTimer += Time.deltaTime; zoomToTimer = Mathf.Clamp(zoomToTimer, 0, zoomToTime); float t = zoomToPointCurve.Evaluate(zoomToTimer / zoomToTime); Holoplay.Instance.transform.position = Vector3.Lerp(startZoomPosition, zoomToPosition, t); if (zoomToTimer == zoomToTime) { zoomingToPosition = false; zoomToTimer = 0f; validRotationStart = false; } else { HandleDoubleClick(); return; } } if (canInteract && !overUI) { RotateInputStart(); Pan(); Zoom(); } RotateInputContinue(overUI); if (!touchInputThisFrame || Input.touchCount == 1) //This seems sketch { Rotate(); } }
void Update() { if (!eventSystem.IsPointerOverGameObject()) { UpdateTarget(); UpdateTargetLast(); if (Input.GetMouseButtonDown(0)) { if (target) { switch (mouseSelection) { case MouseSelection.Wall: gridManager.SetWall(target.x, target.y, !target.wall); break; case MouseSelection.Origen: gridManager.SetOrigen(target.x, target.y); break; case MouseSelection.Target: gridManager.SetTarget(target.x, target.y); break; default: Debug.LogError("flim flam"); break; } } targetOrigen = target; } if (Input.GetMouseButton(0)) { if (target && targetOrigen) { switch (mouseSelection) { case MouseSelection.Wall: gridManager.SetWall(target.x, target.y, targetOrigen.wall); break; case MouseSelection.Origen: gridManager.SetOrigen(target.x, target.y); break; case MouseSelection.Target: gridManager.SetTarget(target.x, target.y); break; default: Debug.LogError("flim flam"); break; } } } } else { target = null; UpdateTargetLast(); } }