CheatCameraView = CheatCameraView or BaseClass(BaseView) local CheatCameraView = CheatCameraView function CheatCameraView:__init() self.base_file = "cheat" self.layout_file = "CheatCameraView" self.layer_name = "Top" self.destroy_imm = true self.use_background = false self.change_scene_close = true self.load_callback = function () self:LoadSuccess() self:AddEvent() end self.open_callback = function ( ) self:OpenSuccess() end self.destroy_callback = function ( ) self:DestroySuccess() end end function CheatCameraView:Open( ) --self.data = data BaseView.Open(self) end function CheatCameraView:LoadSuccess() self.distanceName = self:GetChild("distanceName"):GetComponent("Text") self.distanceInput = self:GetChild("distanceInput"):GetComponent("InputField") self.fieldName = self:GetChild("fieldName"):GetComponent("Text") self.fieldInput = self:GetChild("fieldInput"):GetComponent("InputField") self.rotateName = self:GetChild("rotateName"):GetComponent("Text") self.rotateInput = self:GetChild("rotateInput"):GetComponent("InputField") self.heigthName = self:GetChild("heigthName"):GetComponent("Text") self.heigthInput = self:GetChild("heigthInput"):GetComponent("InputField") self.sureBtn = self:GetChild("sureBtn").gameObject self.copyBtn = self:GetChild("copyBtn").gameObject SetAnchoredPosition(self.transform, -ScreenWidth/2, 0) end function CheatCameraView:AddEvent() local function onBtnClickHandler( target ) if target == self.sureBtn then self:UpdateView() MainCamera.Instance.real_now_pos = co.Vector2(0,0) local main_role = Scene.Instance.main_role if main_role then MainCamera.Instance:ChangePosFllowMainrole(main_role.real_pos.x, main_role.real_pos.y, main_role.jump_height) end MainCamera.Instance:SetUpdateCameraEnabled(true) MainCamera.Instance:SetCameraSize(CameraDefaultFieldofView) elseif target == self.copyBtn then self:CopyData() end end AddClickEvent(self.sureBtn, onBtnClickHandler) AddClickEvent(self.copyBtn, onBtnClickHandler) end function CheatCameraView:OpenSuccess() self:UpdateView() end function CheatCameraView:UpdateView() local temp_dist_value = self.distanceInput.text if temp_dist_value == "" or not temp_dist_value then temp_dist_value = CameraDistanceWithMainRole end local temp_dist_name = "摄像机和主角的平面距离 ("..temp_dist_value.."):" self.distanceName.text = temp_dist_name CameraDistanceWithMainRole = temp_dist_value local temp_field_value = self.fieldInput.text if temp_field_value == "" or not temp_field_value then temp_field_value = CameraDefaultFieldofView end local temp_field_name = "摄像机可视范围 ("..temp_field_value.."):" self.fieldName.text = temp_field_name CameraDefaultFieldofView = temp_field_value local temp_rotate_value = self.rotateInput.text if temp_rotate_value == "" or not temp_rotate_value then temp_rotate_value = SceneCameraRotate end local temp_roate_name = "摄像机和地面夹角 ("..temp_rotate_value.."):" self.rotateName.text = temp_roate_name SceneCameraRotate = temp_rotate_value local temp_heigth_value = self.heigthInput.text if temp_heigth_value == "" or not temp_heigth_value then temp_heigth_value = SceneCameraHeigth end local temp_heigth_name = "摄像机离地面高度 ("..temp_heigth_value.."):" self.heigthName.text = temp_heigth_name SceneCameraHeigth = temp_heigth_value end function CheatCameraView:CopyData( ) local str1 = string.format("--%s\n%s = %.1f", "摄像机和主角的平面距离", "CameraDistanceWithMainRole", CameraDistanceWithMainRole) local str2 = string.format("\n--%s\n%s = %.1f", "摄像机可视范围", "CameraDefaultFieldofView", CameraDefaultFieldofView) local str3 = string.format("\n--%s\n%s = %.1f", "摄像机和地面夹角", "SceneCameraRotate", SceneCameraRotate) local str4 = string.format("\n--%s\n%s = %.1f", "摄像机离地面高度", "SceneCameraHeigth", SceneCameraHeigth) local str = str1 .. str2 .. str3 .. str4 Optimizer.CopyOnPC(str) Message.show("复制成功") end function CheatCameraView:DestroySuccess( ) end