96SEO 2026-02-19 22:06 18
。

为了避免重复造轮子#xff0c;本文总结并提供了一些常用UI界面的实现逻辑。
希望可以帮助大家快速开发通用界面模块#xff0c;也可以在次基础上进行扩展修改常常会遇到一些通用的界面逻辑它不论在什么类型的游戏中都会出现。
为了避免重复造轮子本文总结并提供了一些常用UI界面的实现逻辑。
希望可以帮助大家快速开发通用界面模块也可以在次基础上进行扩展修改以适应你项目的需求。
root.Find(txt_Title).GetComponentText();txt_content
root.Find(txt_Content).GetComponentText();btn_Yes
root.Find(btn/btn_Yes).GetComponentButton();btn_No
root.Find(btn/btn_No).GetComponentButton();txt_title.text
yesAction);BindBtnLogic(btn_No,
noAction);btn_Yes.gameObject.SetActive(yesAction
null);btn_No.gameObject.SetActive(noAction
action){btn.onClick.RemoveAllListeners();if
null){btn.onClick.AddListener(action);}}
通过按钮来实现。
虽然使用Toggle也可以实现但是在实际开发中会发现使用toggle不好控制选中事件的触发和选中状态表现。
通过按钮来自定义组件可以更好地控制逻辑的调用和标签的显示。
-1;InitCount(4);BindSelectCallback(0,
{Debug.Log(查看背包);}));BindSelectCallback(1,
{Debug.Log(查看英雄);}));BindSelectCallback(2,
{Debug.Log(查看商店);}));BindSelectCallback(3,
{Debug.Log(查看活动);}));OnSelectLogic(0);}///
count){_objList.Clear();ClearAllChild(tabRoot);for
tabRoot);obj.SetActive(true);var
trans.Find(btn/offBg/offTxt).GetComponentText(),onTxt
trans.Find(btn/onBg/onTxt).GetComponentText(),onBg
trans.Find(btn/onBg).gameObject,offBg
trans.Find(btn/offBg).gameObject,btn
trans.Find(btn).GetComponentButton(),};var
{OnSelectLogic(index);});_objList.Add(node);}}///
(_callbackDic.ContainsKey(index)){Debug.LogError(已经注册过了);return;}if
null){Debug.LogError(回调为空);return;}if
_objList.Count){Debug.LogError(索引越界);return;}var
_objList[index];node.onTxt.text
txt;_callbackDic.Add(index,callback);}///
_selectIndex){return;}_selectIndex
_callbackDic.TryGetValue(_selectIndex,
(isExist){callback?.Invoke();SetSelectStatus(index);}}///
_objList[i];node.onBg.SetActive(isActive);node.offBg.SetActive(!isActive);}}//清除指定父节点下的所有子物体private
parentRoot.GetChild(i);DestroyImmediate(child.gameObject);}}//绑定按钮点击回调private
action){btn.onClick.RemoveAllListeners();if
null){btn.onClick.AddListener(action);}}
(Input.GetKeyDown(KeyCode.Space)){ShowTip(货币不足);}}void
obj.GetComponentRectTransform();var
obj.GetComponentCanvasGroup();var
obj.transform.Find(txt).GetComponentText();txt.text
tipStr;obj.SetActive(true);group.alpha
1;ResetLocal(obj.transform);rectValue.DOAnchorPosY(flyHeight,
{tipPool.Release(obj);});});}//初始化对象池void
tipRoot);obj.SetActive(false);return
{//获取对象调用go.SetActive(true);ResetLocal(go.transform);},(go)
在对象放回池子时调用go.SetActive(false);ResetLocal(go.transform);go.transform.SetParent(tipRoot);},(go)
Vector3.zero;trans.localEulerAngles
objectPool;//最多显示的提示栏数量超过就隐藏private
QueueGameObject();//是否可继续生成提示栏防止频繁点击造成异常private
tipObj.GetComponentRectTransform();tipHeight
rect.rect.height;InitTipPool();}private
displayTime){ClearAllMsg();timer
(Input.GetKeyDown(KeyCode.Space)){ShowTip(货币不足);}}public
obj.GetComponentRectTransform();var
obj.GetComponentCanvasGroup();var
item.GetComponentRectTransform();rectValue.DOAnchorPosY(rectValue.anchoredPosition.ytipHeightoffset,
0.2f);}});sequence.AppendInterval(0.2f);}sequence.AppendCallback(()
1;obj.transform.SetParent(root);obj.transform.localScale
1);obj.SetActive(true);rect1.anchoredPosition
Vector2.zero;visualTipQueue.Enqueue(obj);tipCount;var
obj.transform.Find(txt).GetComponentText();txt.text
visualTipQueue.Dequeue();tipPool.Release(result);tipCount--;}});sequence.Append(obj.transform.DOScale(Vector3.one,
0.1f));sequence.AppendInterval(0.1f);sequence.OnComplete(()
objectPool);obj.SetActive(false);return
{//获取对象调用go.SetActive(true);ResetLocal(go.transform);},(go)
在对象放回池子时调用go.SetActive(false);ResetLocal(go.transform);go.transform.SetParent(objectPool);},(go)
Vector3.zero;trans.localEulerAngles
child.GetComponentCanvasGroup();var
child.GetComponentRectTransform();var
DOTween.Sequence();sequence.AppendInterval(0.1f
i);sequence.Append(rectValue.DOAnchorPosY(rectValue.anchoredPosition.y
0.2f));sequence.Append(group.DOFade(0,
{visualTipQueue.Dequeue();tipPool.Release(child.gameObject);tipCount--;}));}}
本组件一般出现在查看英雄界面点击左右两个按钮切换查看按钮的详细信息。
在英雄列表中第一个英雄的左按钮不显示最后一个英雄的右按钮不显示。
${index}/{sumCount};});CheckBtnActive();BindBtnLogic(btn_Left,
nextIndex;CheckBtnActive();});BindBtnLogic(btn_Right,
nextIndex;CheckBtnActive();});}public
1){btn_Left.gameObject.SetActive(false);btn_Right.gameObject.SetActive(false);}else{btn_Left.gameObject.SetActive(curIndex
1);btn_Right.gameObject.SetActive(curIndex
1;callback?.Invoke(showIndex);}//绑定按钮点击回调private
action){btn.onClick.RemoveAllListeners();if
null){btn.onClick.AddListener(action);}}
(Input.GetKeyDown(KeyCode.Space)){SetDesc(帮助,
(Input.GetKeyDown(KeyCode.A)){var
desc;LayoutRebuilder.ForceRebuildLayoutImmediate(content);}
(Input.GetKeyDown(KeyCode.Space)){var
$id:{id}好好学习天天向上;AddMarqueeMsg(id,str,1);}if(marqueeMsg.Count
true;tmpTxt.rectTransform.anchoredPosition
marqueeMsg.Peek();idList.Remove(data.id);DisplayMarqueeMsg(data.msg,data.loopCount,
nameloopCount循环播放时间/parampublic
(idList.Contains(msgId)){Debug.LogError(消息已在预播队列);return;}if
1;}idList.Add(msgId);marqueeMsg.Enqueue(new
nameloopCount循环播放时间/parampublic
msg;LayoutRebuilder.ForceRebuildLayoutImmediate(tmpTxt.rectTransform);var
tmpTxt.rectTransform.rect.widthmaskWidth;var
GetDuration(width);tmpTxt.rectTransform.DOAnchorPosX(-width,
duration).SetEase(Ease.Linear).SetLoops(loopCount,
LoopType.Restart).OnComplete(()
{callback?.Invoke();});}//根据消息长度计算动画匀速运行时间private
作为专业的SEO优化服务提供商,我们致力于通过科学、系统的搜索引擎优化策略,帮助企业在百度、Google等搜索引擎中获得更高的排名和流量。我们的服务涵盖网站结构优化、内容优化、技术SEO和链接建设等多个维度。
| 服务项目 | 基础套餐 | 标准套餐 | 高级定制 |
|---|---|---|---|
| 关键词优化数量 | 10-20个核心词 | 30-50个核心词+长尾词 | 80-150个全方位覆盖 |
| 内容优化 | 基础页面优化 | 全站内容优化+每月5篇原创 | 个性化内容策略+每月15篇原创 |
| 技术SEO | 基本技术检查 | 全面技术优化+移动适配 | 深度技术重构+性能优化 |
| 外链建设 | 每月5-10条 | 每月20-30条高质量外链 | 每月50+条多渠道外链 |
| 数据报告 | 月度基础报告 | 双周详细报告+分析 | 每周深度报告+策略调整 |
| 效果保障 | 3-6个月见效 | 2-4个月见效 | 1-3个月快速见效 |
我们的SEO优化服务遵循科学严谨的流程,确保每一步都基于数据分析和行业最佳实践:
全面检测网站技术问题、内容质量、竞争对手情况,制定个性化优化方案。
基于用户搜索意图和商业目标,制定全面的关键词矩阵和布局策略。
解决网站技术问题,优化网站结构,提升页面速度和移动端体验。
创作高质量原创内容,优化现有页面,建立内容更新机制。
获取高质量外部链接,建立品牌在线影响力,提升网站权威度。
持续监控排名、流量和转化数据,根据效果调整优化策略。
基于我们服务的客户数据统计,平均优化效果如下:
我们坚信,真正的SEO优化不仅仅是追求排名,而是通过提供优质内容、优化用户体验、建立网站权威,最终实现可持续的业务增长。我们的目标是与客户建立长期合作关系,共同成长。
Demand feedback