public void HandleClick(Vector2 scr_pos, bool can_touch_ground) { Camera main_camera = Main.Main3DCamera; if (main_camera != null) { Vector3 scr_pos3 = new Vector3(scr_pos.x, scr_pos.y); RaycastHit hit_info; Ray ray = main_camera.ScreenPointToRay(scr_pos3); int ray_mask; if (can_touch_ground) { ray_mask = CUnityUtil.LayerMaskEntity | CUnityUtil.LayerMaskClickable | CUnityUtil.LayerMaskTerrainBuilding; } else { ray_mask = CUnityUtil.LayerMaskHostPlayer; } if (Physics.Raycast(ray, out hit_info, Mathf.Infinity, ray_mask)) { Collider cd = hit_info.collider; if (cd == null) { return; } if (cd.gameObject.layer == CUnityUtil.Layer_Terrain) { Vector3 pos = hit_info.point; LuaScriptMgr.Instance.CallLuaOnClickGroundFunc(pos); } else if (cd.gameObject.layer == CUnityUtil.Layer_Building) { Vector3 pos = hit_info.point; pos.y = CUnityUtil.GetMapHeight(pos); LuaScriptMgr.Instance.CallLuaOnClickGroundFunc(pos); } else if (cd.gameObject.layer != CUnityUtil.Layer_Unblockable) { ObjectBehaviour oc = cd.gameObject.GetComponentInParent <ObjectBehaviour>(); if (oc != null) { oc.OnClick(); } } } } }