|
|
- CheatUICameraView = CheatUICameraView or BaseClass(BaseView)
- local CheatUICameraView = CheatUICameraView
-
- function CheatUICameraView:__init()
- self.base_file = "cheat"
- self.layout_file = "CheatUICameraView"
- 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 CheatUICameraView:Open( )
- --self.data = data
- BaseView.Open(self)
- end
-
- function CheatUICameraView:LoadSuccess()
- self.uicamrotateXName = self:GetChild("uicamrotateXName"):GetComponent("Text")
- self.uicamrotateXInput = self:GetChild("uicamrotateXInput"):GetComponent("InputField")
- self.uicamrotateYName = self:GetChild("uicamrotateYName"):GetComponent("Text")
- self.uicamrotateYInput = self:GetChild("uicamrotateYInput"):GetComponent("InputField")
- self.uicamPosXName = self:GetChild("uicamPosXName"):GetComponent("Text")
- self.uicamPosXInput = self:GetChild("uicamPosXInput"):GetComponent("InputField")
- self.uicamPosYName = self:GetChild("uicamPosYName"):GetComponent("Text")
- self.uicamPosYInput = self:GetChild("uicamPosYInput"):GetComponent("InputField")
- self.uicamPosZName = self:GetChild("uicamPosZName"):GetComponent("Text")
- self.uicamPosZInput = self:GetChild("uicamPosZInput"):GetComponent("InputField")
- self.uicamfieldName = self:GetChild("uicamfieldName"):GetComponent("Text")
- self.uicamfieldInput = self:GetChild("uicamfieldInput"):GetComponent("InputField")
-
- self.sureBtn = self:GetChild("sureBtn").gameObject
- self.copyBtn = self:GetChild("copyBtn").gameObject
-
- SetAnchoredPosition(self.transform, 0, 0)
- end
-
- function CheatUICameraView:AddEvent()
- local function onBtnClickHandler( target )
- if target == self.sureBtn then
- local camera_obj = self.camera_obj
- if not camera_obj then
- Message.show("模型摄像机还没创建好")
- end
- local cam = camera_obj.transform:GetComponent("Camera")
- local temp_rotate = self.camera_obj.transform.rotation.eulerAngles
-
- local temp_rotate_x = tonumber(self.uicamrotateXInput.text)
- if temp_rotate_x then
- temp_rotate = Vector3(temp_rotate_x, temp_rotate.y, 0)
- end
- local temp_rotate_y = tonumber(self.uicamrotateYInput.text)
- if temp_rotate_y then
- temp_rotate = Vector3(temp_rotate.x, temp_rotate_y, 0)
- end
- print("tanar: [CheatUICameraView 67]=> temp_rotate: ",temp_rotate)
- camera_obj.transform.localRotation = Quaternion.Euler(temp_rotate)
-
- local temp_offset = tonumber(self.uicamPosXInput.text)
- if temp_offset then
- SetLocalPositionX(camera_obj.transform, temp_offset)
- end
-
- local temp_height = tonumber(self.uicamPosYInput.text)
- if temp_height then
- SetLocalPositionY(camera_obj.transform, temp_height)
- end
-
- local temp_distance = tonumber(self.uicamPosZInput.text)
- if temp_distance then
- SetLocalPositionZ(camera_obj.transform, temp_distance)
- end
-
- local temp_field = tonumber(self.uicamfieldInput.text)
- if temp_field then
- cam.fieldOfView = temp_field
- end
-
- self:UpdateView()
- GlobalEventSystem:Fire(EventName.UPDATE_UIMODEL_CAMERA_DEFAULT_ARGS)
- elseif target == self.copyBtn then
- self:CopyData()
- end
- end
- AddClickEvent(self.sureBtn, onBtnClickHandler)
- AddClickEvent(self.copyBtn, onBtnClickHandler)
- end
-
- function CheatUICameraView:OpenSuccess()
- self:UpdateView()
- end
-
- function CheatUICameraView:UpdateView()
- self.camera_obj = LuaViewManager.role_back_camera
- if not self.camera_obj then
- self.camera_obj = GameObject.Find("root").transform:Find("UIBackRoleCamera")
- end
- if not self.camera_obj then
- Message.show("模型摄像机还没创建好")
- return
- end
- local pos = self.camera_obj.transform.localPosition
- local rotate = self.camera_obj.transform.localRotation
- local vet3 = self.camera_obj.transform.rotation.eulerAngles
- local cam = self.camera_obj.transform:GetComponent("Camera")
- local filed = cam.fieldOfView
-
- local temp_uicam_rotatex_name = string.format("倾斜RotateX ( %.2f ):", vet3.x)
- self.uicamrotateXName.text = temp_uicam_rotatex_name
-
- local temp_uicam_rotatey_name = string.format("旋转RotateY ( %.2f ):", vet3.y)
- self.uicamrotateYName.text = temp_uicam_rotatey_name
- -- self.uicamrotateXInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Rotate) or ""
-
- local temp_uicam_posx_name = string.format("偏移PosX ( %.2f ):", pos.x)
- self.uicamPosXName.text = temp_uicam_posx_name
-
- local temp_uicam_height_name = string.format("高度PosY ( %.2f ):", pos.y)
- self.uicamPosYName.text = temp_uicam_height_name
- -- self.uicamPosYInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Height) or ""
-
- local temp_uicam_dis_name = "距离PosZ [480-495] (".. pos.z .. "):"
- self.uicamPosZName.text = temp_uicam_dis_name
- -- self.uicamPosYInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Height) or ""
-
- local temp_uicam_field_name = "透视Field (".. filed .. "):"
- self.uicamfieldName.text = temp_uicam_field_name
- -- self.uicamPosYInput.text = tostring(UIModelClassByRT.CAMERA_DEFAULT_ARGS.Height) or ""
- end
-
- function CheatUICameraView:CopyData( )
- local str1 = string.format("--%s\n%s = %.1f", "倾斜RotateX", "rotate.x", self.uicamrotateXInput.text)
- local str2 = string.format("\n--%s\n%s = %.1f", "旋转RotatesY", "rotate.y", self.uicamrotateYInput.text)
- local str3 = string.format("\n--%s\n%s = %.1f", "偏移PosX", "pos.x", self.uicamPosXInput.text)
- local str4 = string.format("\n--%s\n%s = %.1f", "高度PosY", "pos.y", self.uicamPosYInput.text)
- local str5 = string.format("\n--%s\n%s = %.1f", "距离PosZ", "pos.z", self.uicamPosZInput.text)
- local str6 = string.format("\n--%s\n%s = %.1f", "透视Field", "filed", self.uicamfieldInput.text)
- local str = str1 .. str2 .. str3 .. str4 .. str5 .. str6
- Optimizer.CopyOnPC(str)
- Message.show("复制成功")
- end
-
- function CheatUICameraView:DestroySuccess( )
-
- end
|