Example #1
0
        private bool OnTouchDown(Vector3 pointerPosition)
        {
            UnityEngine.EventSystems.EventSystem eventsystem = UnityEngine.EventSystems.EventSystem.current;

            if (eventsystem.IsPointerOverGameObject())
            {
                return(false);
            }

            // --- On Mouse Down ---
            // Check if Movement MouseArea is Hit
            mouseDownPosition = pointerPosition;

            // Do PlaneCast to Check WorldPosition of Mouse
            Plane plane = new Plane(transform.forward, boardOrigin.position);
            Ray   ray   = cameraReference.ScreenPointToRay(pointerPosition);

            if (plane.Raycast(ray, out float enter))
            {
                mouseDownWorldPosition = ray.GetPoint(enter);
                //Debug.DrawLine(boardOrigin.position, mouseDownWorldPosition, Color.white, 10f);

                onMouseDown.Invoke(mouseDownWorldPosition);
                areaClicked = true;
                return(true);
            }

            return(false);
        }
Example #2
0
        // Update is called once per frame
        void Update()
        {
            //Check if pointer is above a gui object, if it is then we should not interact with the world
            if (eventSystem.IsPointerOverGameObject())
            {
                return;
            }

            HandleInput();
            HandleTerraforming();
        }
Example #3
0
        void Update()
        {
            if (GameEnded)
            {
                return;
            }

            Timer = Mathf.MoveTowards(Timer, 0, Time.deltaTime);

            DoNavigation();
            ControlMoneyMessageColor(false);
            CountEnemiesLeft();
            CountTimeTillWaveStart();
            CountEnemiesSpawnerTimer();
            PositioningTower();
            CreatingTower();

            if (Input.GetKeyDown("mouse 0") && !_eventSystem.IsPointerOverGameObject() && TowerToEdit != null)
            {
                DeactivateTowerControl();
            }
        }
Example #4
0
        static int _m_IsPointerOverGameObject(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.EventSystems.EventSystem gen_to_be_invoked = (UnityEngine.EventSystems.EventSystem)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 1)
                {
                    bool gen_ret = gen_to_be_invoked.IsPointerOverGameObject(  );
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2))
                {
                    int _pointerId = LuaAPI.xlua_tointeger(L, 2);

                    bool gen_ret = gen_to_be_invoked.IsPointerOverGameObject(_pointerId);
                    LuaAPI.lua_pushboolean(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.EventSystems.EventSystem.IsPointerOverGameObject!"));
        }
        static StackObject *IsPointerOverGameObject_16(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.EventSystems.EventSystem instance_of_this_method = (UnityEngine.EventSystems.EventSystem) typeof(UnityEngine.EventSystems.EventSystem).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.IsPointerOverGameObject();

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method ? 1 : 0;
            return(__ret + 1);
        }
Example #6
0
        void DoNavigation()
        {
            if (_eventSystem.IsPointerOverGameObject())
            {
                return;
            }

            if (Input.GetKey("mouse 0"))
            {
                Camera.main.transform.position += new Vector3(-Input.GetAxis("Mouse X"), 0, -Input.GetAxis("Mouse Y"));
            }

            Camera.main.transform.position = new Vector3(
                Mathf.Clamp(Camera.main.transform.position.x, X_Min, X_Max),
                Camera.main.transform.position.y,
                Mathf.Clamp(Camera.main.transform.position.z, Z_Min, Z_Max));
        }
Example #7
0
 protected void CheckPointerOverUI()
 {
     UnityEngine.EventSystems.EventSystem system = UnityEngine.EventSystems.EventSystem.current;
     if (system == null)
     {
         m_isPointerOverUI = false;
         return;
     }
     m_isPointerOverUI = system.IsPointerOverGameObject();
     for (int i = 0; i < Input.touchCount; ++i)
     {
         UnityEngine.EventSystems.PointerEventData eventData = new UnityEngine.EventSystems.PointerEventData(system);
         eventData.position = Input.GetTouch(i).position;
         List <UnityEngine.EventSystems.RaycastResult> resultList = new List <UnityEngine.EventSystems.RaycastResult>();
         system.RaycastAll(eventData, resultList);
         m_isPointerOverUI |= resultList.Count != 0;
     }
 }
        //指定位置のコライダーのうち、もっともZ値が低いものを取得
        GameObject CheckPoint(float x, float y, int layerMask)
        {
            UnityEngine.EventSystems.EventSystem currentSystem = UnityEngine.EventSystems.EventSystem.current;
            if (currentSystem != null && currentSystem.IsPointerOverGameObject())
            {
                return(null);
            }

            Collider2D hit = Physics2D.OverlapPoint(new Vector2(x, y), layerMask);

            if (null != hit)
            {
                return(hit.gameObject);
            }
            else
            {
                return(null);
            }
        }
Example #9
0
        // Update is called once per frame
        void Update()
        {
            if (eventSystem.IsPointerOverGameObject() == false)
            {
                switch (editorManager.currentMode)
                {
                case EditorMode.Create:
                    CheckMouseOnCreate();
                    break;

                case EditorMode.Normal:
                    CheckMouseOnNormal();
                    break;

                case EditorMode.Move:
                    CheckMouseOnMove();
                    break;

                default:
                    Debug.LogWarning("추가되지 않은 모드입니다. 새로 추가해주세요.");
                    break;
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////
        private UnityEngine.Vector2 ProjectPointer(float x, float y)
        {
            if (!IsRenderToTexture)
            {
                // Screen coordinates
                return(new UnityEngine.Vector2(x, UnityEngine.Screen.height - y));
            }
            else
            {
                // 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 =
                        _target.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 coordintates, 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 == _target)
                    {
                        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));
            }
        }