private IEnumerator doScreenClick() { while (true) { for (int i = 0; i < Input.touchCount; i++) { var t = Input.GetTouch(i); if (t.phase == TouchPhase.Began && t.position.x / Screen.width > 0.3 && t.position.y / Screen.height > 0.5) { var ray = Camera.main.ScreenPointToRay(t.position); RaycastHit hit; if (EventSystem.current.currentSelectedGameObject == null && Physics.Raycast(ray, out hit)) { Debug.Log(hit.collider.name); var unit = hit.collider.GetComponent <NTGBattleUnitController>(); if (unit != null) { localPlayerController.TargetUnit(unit); } } break; } } #if UNITY_EDITOR if (Input.GetMouseButtonDown(0) && Input.mousePosition.x / Screen.width > 0.3 && Input.mousePosition.y / Screen.height > 0.5) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (EventSystem.current.currentSelectedGameObject == null && Physics.Raycast(ray, out hit)) { Debug.Log(hit.collider.name); var unit = hit.collider.GetComponent <NTGBattleUnitController>(); if (unit != null) { localPlayerController.TargetUnit(unit); } } } #endif yield return(null); } }
static int TargetUnit(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); NTGBattlePlayerController obj = (NTGBattlePlayerController)ToLua.CheckObject(L, 1, typeof(NTGBattlePlayerController)); NTGBattleUnitController arg0 = (NTGBattleUnitController)ToLua.CheckUnityObject(L, 2, typeof(NTGBattleUnitController)); obj.TargetUnit(arg0); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }