Files
JJBB/Assets/Project/Script/LuaScripts/UI/Lua/Camera/CameraControlPanel.txt
2024-08-23 15:49:34 +08:00

195 lines
6.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

require("Util")
require("LuaUtil")
--[=[ 功能描述
1.照相状态时可随意调整场景角度如原3D模式
2.界面左侧显示镜头远近的调整UI(滑动条无法实现),往上拖动为拉近镜头,往下拖动位为拉远镜头。
]=]--
-- 拍照控制界面
CameraControlPanel = {}
-- local SetBtn --设置按钮
local Upbtn -- 上方按钮
local DownBtn -- 下方按钮
local m_Slider -- 滑动条
local screenshotBtn -- 拍照模式按钮
local m_BGBtn
local scale = 80
local SliderValue = 1 -- 每次的变更值
local SliderDefaultValue = 0 -- 初始默认值
--local optionPanelName = "CameraSetOptionPanel" -- 选项界面名
local WorldUIRoot = "WorldUIRoot"
local coRuner = nil
local _LerpTime = 0.5
local _CountTime = 0
function CameraControlPanel.Awake()
--SetBtn = _SetBtn:GetComponent("Button");
Upbtn = _Upbtn:GetComponent("Button");
DownBtn = _DownBtn:GetComponent("Button");
m_Slider = _Slider:GetComponent("Slider");
screenshotBtn = _screenshotBtn:GetComponent("Button");
m_BGBtn = _BGBtn:GetComponent("Button");
coRuner = self:GetComponent("MonoBehaviour")
m_Slider.value = SliderDefaultValue
CameraControlPanel.TheBindingEvent()
end
local asdasd = 1
function CameraControlPanel.OnEnable()
asdasd = 1
CameraControlPanel.HideAllUI(1)
end
function CameraControlPanel.Update()
if self.gameObject.layer ~= 31 then
self.gameObject.layer = 31
end
if asdasd == 1 then
local _MessageTipRoot = CS.UnityEngine.GameObject.Find("MessageTipRoot")
if _MessageTipRoot.transform:Find("MessageBoxRoot(Clone)") ~= nil then
if _MessageTipRoot.transform:Find("MessageBoxRoot(Clone)").activeInHierarchy == true then
local _MessageBoxRoot = _MessageTipRoot.transform:Find("MessageBoxRoot(Clone)").gameObject;
_MessageBoxRoot:SetActive(false);
asdasd = 0
end
end
end
end
--点击事件绑定
function CameraControlPanel.TheBindingEvent()
-- optionPanelName:SetActive(false)
-- SetBtn.onClick:RemoveAllListeners();
-- SetBtn.onClick:AddListener(function()
-- optionPanelName:SetActive(true)
-- end)
Upbtn.onClick:RemoveAllListeners();
Upbtn.onClick:AddListener(function()
CameraControlPanel.ControlScaleCamera(1)
CameraControlPanel.BtnControSlider(1)
end)
DownBtn.onClick:RemoveAllListeners();
DownBtn.onClick:AddListener(function()
CameraControlPanel.ControlScaleCamera(-1)
CameraControlPanel.BtnControSlider(-1)
end)
_BGBtn:SetActive(false)
screenshotBtn.onClick:RemoveAllListeners();
screenshotBtn.onClick:AddListener(function()
CameraControlPanel.OnscreenshotBtnClick(1)
end)
m_BGBtn.onClick:RemoveAllListeners();
m_BGBtn.onClick:AddListener(function()
CameraControlPanel.OnscreenshotBtnClick(0)
end)
end
function CameraControlPanel.OnscreenshotBtnClick(estimate)
_BGBtn:SetActive(estimate == 1)
local UI_Root = CS.UnityEngine.GameObject.Find("UiRoot(Clone)").gameObject
local _UICamera = UI_Root.transform:Find("Camera").gameObject
--_UICamera:GetComponent("Camera").enabled = (estimate ~= 1);
if estimate == 1 then
_UICamera:GetComponent("Camera").cullingMask = 0
else
_UICamera:GetComponent("Camera").cullingMask = -2147483648
end
end
function CameraControlPanel.ControlScaleCamera(m_int)
local WorldUIRootObj = CS.UnityEngine.GameObject.Find(WorldUIRoot)
local WorldUIRootPIM = WorldUIRootObj:GetComponent("ProcessInputModule");
local _scale = m_int * scale
WorldUIRootPIM.processCamera:ScaleCamera(_scale);
end
function CameraControlPanel.BtnControSlider(m_int)
if m_int > 0 then
m_Slider.value = m_Slider.value + SliderValue
else
m_Slider.value = m_Slider.value - SliderValue
end
end
function CameraControlPanel.ControSlider()
if m_Slider.value > SliderDefaultValue then
CameraControlPanel.ControlScaleCamera(1)
else
CameraControlPanel.ControlScaleCamera(-1)
end
end
function CameraControlPanel.OnDisable()
CameraControlPanel.HideAllUI(0)
end
function CameraControlPanel.HideAllUI(isShow)
local UI_Root = CS.UnityEngine.GameObject.Find("UiRoot(Clone)").gameObject
local _UICamera = UI_Root.transform:Find("Camera").gameObject
-- UI === 32
if isShow == 0 then
_UICamera:GetComponent("Camera").cullingMask = 32
else
_UICamera:GetComponent("Camera").cullingMask = -2147483648
end
local _BaseRight = UI_Root.transform:Find("BaseUIRoot");
if _BaseRight.transform:Find("BaseRight/ActiveBtns(Clone)") ~= nil then
local _ActiveBtns = _BaseRight.transform:Find("BaseRight/ActiveBtns(Clone)").gameObject;
_ActiveBtns:SetActive(isShow ~= 1);
end
if _BaseRight.transform:Find("BaseRight/SkillBarRoot(Clone)") ~= nil then
local _SkillBarRoot = _BaseRight.transform:Find("BaseRight/SkillBarRoot(Clone)").gameObject;
_SkillBarRoot:SetActive(isShow ~= 1);
end
if _BaseRight.transform:Find("BaseLeft/ChatFrameRoot(Clone)") ~= nil then
local _ChatFrameRoot = _BaseRight.transform:Find("BaseLeft/ChatFrameRoot(Clone)/ChatFrameAnchor").gameObject;
_ChatFrameRoot:SetActive(isShow ~= 1);
end
if _BaseRight.transform:Find("BaseLeft/MissionDialogAndLeftTabsRoot(Clone)") ~= nil then
local _MissionDialogAndLeftTabsRoot = _BaseRight.transform:Find("BaseLeft/MissionDialogAndLeftTabsRoot(Clone)").gameObject;
_MissionDialogAndLeftTabsRoot:GetComponent("MissionDialogAndLeftTabsLogic"):OnBtnShow()
end
if _BaseRight.transform:Find("ExtraFunTipRoot(Clone)") ~= nil then
local _ExtraFunTipRoot = _BaseRight.transform:Find("ExtraFunTipRoot(Clone)").gameObject;
_ExtraFunTipRoot:SetActive(isShow ~= 1);
end
local WorldUIRootObj = CS.UnityEngine.GameObject.Find(WorldUIRoot)
if WorldUIRootObj.transform:Find("JoyStickRoot(Clone)") ~= nil then
local _JoyStickRoot = WorldUIRootObj.transform:Find("JoyStickRoot(Clone)").gameObject;
_JoyStickRoot:SetActive(isShow ~= 1);
end
end