游戏界面的提示帮助(根据鼠标点击选取显示位置)
来源:互联网 发布:桔子桌面软件 编辑:程序博客网 时间:2024/06/11 01:24
--显示提示 文字组 和目标点坐标
--tipsArr为要显示的内容 逐条\n换行如截图
function LuaCUIFunctionHelp.ShowFunctionHelp(tipsArr)if #(tipsArr) == 0 then
return;
end
LuaCUIFunctionHelp.ShowUI();
--合成要输出的内容 逐条换行
local strCommonText = "";
local scrollText = m_gameObject.transform:FindChild("imgback/Viewport/Content/scroll"); --界面内容框
if (scrollText ~= nil) then
local textComponent = scrollText.gameObject:GetComponent("Text");
if textComponent ~= nil then
for i = 1,#(tipsArr) do
strCommonText = strCommonText .. tipsArr[i].. "\n";
end
textComponent.text = strCommonText;
end
end
--设置提示框的长度
local m_nHeight = 0;
local m_nWidth = 0;
local scrollText = m_gameObject.transform:FindChild("imgback/Viewport/Content/scroll");
local rectScrollSize = scrollText.gameObject:GetComponent("Text").preferredHeight;
if rectScrollSize ~= nil then
rectScrollSizeHeight = rectScrollSize.preferredHeight;
end
if rectScrollSizeHeight <= 300 then
m_nHeight = rectScrollSizeHeight + 20;
m_nWidth = 290;
else
m_nHeight = 300;
m_nWidth = 290;
end
--设置背景高度和宽度
LuaCUIFunctionHelp.SetBackSize(m_nWidth,m_nHeight);
--设置帮助界面的坐标
local tipsRect = m_gameObject:GetComponent("RectTransform");
if(tipsRect ~= nil) then
tipsRect.sizeDelta = UnityEngine.Vector2.New( math.abs(m_nWidth), math.abs(m_nHeight));
local nPosX = 0;
if(UnityEngine.Input.mousePosition.x + tipsRect.rect.width + 30 >= UnityEngine.Screen.width) then
nPosX = UnityEngine.Input.mousePosition.x - 10;
else
nPosX = UnityEngine.Input.mousePosition.x;
end
local nPosY = 0;
if(UnityEngine.Input.mousePosition.y - tipsRect.rect.height + 30 <= 0) then
nPosY = tipsRect.rect.height + 30;
else
nPosY = UnityEngine.Input.mousePosition.y - 10;
end
tipsRect.anchoredPosition = UnityEngine.Vector2.New(nPosX, nPosY);
end
end
--设置背景高度和宽度
function LuaCUIFunctionHelp.SetBackSize(lWidth,lHeight)
local mBack = m_gameObject.transform:FindChild("imgback").gameObject;
if(mBack ~= nil) then
local rectTransform = mBack.gameObject:GetComponent("RectTransform");
if(rectTransform ~= nil) then
rectTransform.sizeDelta = Vector2.New(lWidth, lHeight);
end
end
end
阅读全文
1 0
- 游戏界面的提示帮助(根据鼠标点击选取显示位置)
- 根据鼠标位置显示div
- 根据鼠标点击位置移动物体
- wpf 对话框显示在鼠标点击的位置
- jquery悬浮窗,根据鼠标位置显示
- js获取鼠标点击位置(界面的位置,可以使用top和left直接定位的)
- 获取鼠标点击的位置
- 点击 鼠标 图片跟着鼠标的位置
- Unity中让UI界面根据鼠标位置摇晃代码
- 让图片直线移动到鼠标点击位置,类似游戏里的人物走动!
- 让图片直线移动到鼠标点击位置,类似游戏里的人物走动!
- 根据点击的位置调整精灵方向(弧度)
- Extjs之DateField控件的鼠标点击选取事件监控
- 搜索帮助中根据界面条件显示实现方法一
- 网页效果获取鼠标点击的位置
- javascript - 得到鼠标点击的相对位置
- js获取鼠标点击的位置
- 鼠标点击不同位置触发的事件
- 广播和通知的简单介绍
- 构造代码块、静态代码块、构造方法的执行顺序
- mysql数据库面试总结
- 三、python小程序实例(python编写cgi服务)
- Android Battery视图界面分析
- 游戏界面的提示帮助(根据鼠标点击选取显示位置)
- [BZOJ2240]积木游戏
- NOIP机房模拟 【计算几何】【花花的聚会】【文本编辑器】
- 【Azure】CentOs虚拟机创建及NGUNX安装
- C++各种指针声明
- 利用jxl读取xls文件
- nodejs使用domain捕获工作进程异常
- 常用git命令
- array_map函数在PHP类中调用内部方法简介