Unity 通用UI界面逻辑总结
概述
在游戏开发中,常常会遇到一些通用的界面逻辑,它不论在什么类型的游戏中都会出现。为了避免重复造轮子,本文总结并提供了一些常用UI界面的实现逻辑。希望可以帮助大家快速开发通用界面模块,也可以在次基础上进行扩展修改,以适应你项目的需求。
工程链接:GitCode - 全球开发者的开源社区,开源代码托管平台
二次确认界面
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;public class ConfirmDialog : MonoBehaviour
{private Text txt_title;private Text txt_content;private Button btn_Yes;private Button btn_No;void Start(){var root = gameObject.transform;txt_title = root.Find("txt_Title").GetComponent<Text>();txt_content = root.Find("txt_Content").GetComponent<Text>();btn_Yes = root.Find("btn/btn_Yes").GetComponent<Button>();btn_No = root.Find("btn/btn_No").GetComponent<Button>();txt_title.text = "提示";//测试代码InitDialog("好好学习,天天向上!", () => {Debug.Log("Yes"); },() => {Debug.Log("No"); });}/// <summary>/// 重载一:使用默认标题 “提示”/// </summary>/// <param name="content">需要确认的内容</param>/// <param name="yesAction">确认按钮回调</param>/// <param name="noAction">取消按钮回调</param>public void InitDialog(string content, UnityAction yesAction = null, UnityAction noAction = null){txt_title.text = "提示";CoreLogic(content, yesAction, noAction);}/// <summary>/// 重载一:使用自定义标题/// </summary>/// <param name="title">自定义标题</param>/// <param name="content">需要确认的内容</param>/// <param name="yesAction">确认按钮回调</param>/// <param name="noAction">取消按钮回调</param>public void InitDialog(string title, string content, UnityAction yesAction = null, UnityAction noAction = null){txt_title.text = title;CoreLogic(content, yesAction, noAction);}//公共逻辑提取private void CoreLogic(string content, UnityAction yesAction = null, UnityAction noAction = null){txt_content.text = content;BindBtnLogic(btn_Yes, yesAction);BindBtnLogic(btn_No, noAction);btn_Yes.gameObject.SetActive(yesAction != null);btn_No.gameObject.SetActive(noAction != null);}//绑定按钮点击回调private void BindBtnLogic(Button btn, UnityAction action){btn.onClick.RemoveAllListeners();if (action != null){btn.onClick.AddListener(action);}}
}
切页标签
通过按钮来实现。虽然使用Toggle也可以实现,但是在实际开发中会发现使用toggle不好控制选中事件的触发和选中状态表现。通过按钮来自定义组件可以更好地控制逻辑的调用和标签的显示。
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;class TabNode
{ public int index;public GameObject offBg;public GameObject onBg;public Text offTxt;public Text onTxt;public Button btn;public UnityAction callback;
}public class SwitchPageTab : MonoBehaviour
{public Transform tabRoot;//标签组的父节点public GameObject tabObj;//标签页预制体模板private int _selectIndex;//选中的标签页索引private List<TabNode> _objList = new List<TabNode>();private Dictionary<int, UnityAction> _callbackDic = new Dictionary<int, UnityAction>();private void Start(){_selectIndex = -1;InitCount(4);BindSelectCallback(0, "背包", (() =>{Debug.Log("查看背包");}));BindSelectCallback(1, "英雄", (() =>{Debug.Log("查看英雄");}));BindSelectCallback(2, "商店", (() =>{Debug.Log("查看商店");}));BindSelectCallback(3, "活动", (() =>{Debug.Log("查看活动");}));OnSelectLogic(0);}/// <summary>/// 初始化调用/// </summary>/// <param name="count">标签的数量</param>public void InitCount(int count){_objList.Clear();ClearAllChild(tabRoot);for (var i = 0; i < count; i++){var obj = Instantiate(tabObj, tabRoot);obj.SetActive(true);var trans = obj.transform;var node = new TabNode{offTxt = trans.Find("btn/offBg/offTxt").GetComponent<Text>(),onTxt = trans.Find("btn/onBg/onTxt").GetComponent<Text>(),onBg = trans.Find("btn/onBg").gameObject,offBg = trans.Find("btn/offBg").gameObject,btn = trans.Find("btn").GetComponent<Button>(),};var index = i;BindBtnLogic(node.btn, () =>{OnSelectLogic(index);});_objList.Add(node);}}/// <summary>/// 绑定指定页签索引的回调函数/// </summary>/// <param name="index">页签索引</param>/// <param name="txt">页签问本</param>/// <param name="callback">选中回调</param>public void BindSelectCallback(int index,string txt,UnityAction callback){if (_callbackDic.ContainsKey(index)){Debug.LogError("已经注册过了!");return;}if (callback == null){Debug.LogError("回调为空!");return;}if (index < 0 || index > _objList.Count){Debug.LogError("索引越界!");return;}var node = _objList[index];node.onTxt.text = txt;node.offTxt.text = txt;_callbackDic.Add(index,callback);}/// <summary>/// 调用指定索引对应的回调函数/// </summary>/// <param name="index"></param>private void OnSelectLogic(int index){if (index == _selectIndex){return;}_selectIndex = index;var isExist = _callbackDic.TryGetValue(_selectIndex, out UnityAction callback);if (isExist){callback?.Invoke();SetSelectStatus(index);}}/// <summary>/// 控制指定页签的UI表现/// </summary>/// <param name="index"></param>private void SetSelectStatus(int index){var count = _objList.Count;for (var i = 0; i < count; i++){var isActive = index == i;var node = _objList[i];node.onBg.SetActive(isActive);node.offBg.SetActive(!isActive);}}//清除指定父节点下的所有子物体private void ClearAllChild(Transform parentRoot){var childCount = parentRoot.childCount;for (var i = childCount - 1; i >= 0; i--){var child = parentRoot.GetChild(i);DestroyImmediate(child.gameObject);}}//绑定按钮点击回调private void BindBtnLogic(Button btn, UnityAction action){btn.onClick.RemoveAllListeners();if (action != null){btn.onClick.AddListener(action);}}
}
飘字提示
简易版本
using UnityEngine;
using UnityEngine.Pool;
using DG.Tweening;
using UnityEngine.UI;public class SimpleTip : MonoBehaviour
{//提示栏预制体public GameObject tipObj;//提示栏显示的父节点public Transform tipRoot;//对象池private ObjectPool<GameObject> tipPool;//飞行高度private float flyHeight = 500;void Start(){InitTipPool();}void Update(){if (Input.GetKeyDown(KeyCode.Space)){ShowTip("货币不足!");}}void ShowTip(string tipStr){var obj = tipPool.Get();var rectValue = obj.GetComponent<RectTransform>();var group = obj.GetComponent<CanvasGroup>();var txt = obj.transform.Find("txt").GetComponent<Text>();txt.text = tipStr;obj.SetActive(true);group.alpha = 1;ResetLocal(obj.transform);rectValue.DOAnchorPosY(flyHeight, 1f).OnComplete(() =>{group.DOFade(0, 0.1f).OnComplete(() =>{tipPool.Release(obj);});});}//初始化对象池void InitTipPool(){tipPool = new ObjectPool<GameObject>(() =>{//创建新对象调用var obj = Instantiate(tipObj, tipRoot);obj.SetActive(false);return obj;},(go) =>{//获取对象调用go.SetActive(true);ResetLocal(go.transform);},(go) =>{// 在对象放回池子时调用go.SetActive(false);ResetLocal(go.transform);go.transform.SetParent(tipRoot);},(go) =>{Destroy(go); });}//重置本地信息void ResetLocal(Transform trans){trans.localPosition = Vector3.zero;trans.localEulerAngles = Vector3.zero;trans.localScale = Vector3.one;}
}
升级版本
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Pool;public class GoodTip : MonoBehaviour
{//提示栏显示的父节点public Transform root;//提示栏模板预制体public GameObject tipObj;//对象池节点public Transform objectPool;//最多显示的提示栏数量,超过就隐藏private int limitCount = 5;//提示栏之间的偏移private float offset = 20;//提示飞行高度private float flyHeight = 100;//提示栏生成数量,只用于逻辑运算private int tipCount = 0;//提示栏高度private float tipHeight;private Queue<GameObject> visualTipQueue = new Queue<GameObject>();//是否可继续生成提示栏,防止频繁点击造成异常private bool isOk = true;private float timer = 0f;private bool startTimer = false;private float displayTime = 0.65f;//提示停留展示时间private ObjectPool<GameObject> tipPool;void Start(){var rect = tipObj.GetComponent<RectTransform>();tipHeight = rect.rect.height;InitTipPool();}private void Update(){if (startTimer){//定时统一清理提示消息timer += Time.deltaTime;if (timer > displayTime){ClearAllMsg();timer = 0f;startTimer = false;}}if (Input.GetKeyDown(KeyCode.Space)){ShowTip("货币不足!");}}public void ShowTip(string tip){if (!isOk){return;}startTimer = false;isOk = false;var obj = tipPool.Get();var rect1 = obj.GetComponent<RectTransform>();var group = obj.GetComponent<CanvasGroup>();var sequence = DOTween.Sequence();if (visualTipQueue.Count > 0){sequence.AppendCallback(() =>{foreach (var item in visualTipQueue){var rectValue = item.GetComponent<RectTransform>();rectValue.DOAnchorPosY(rectValue.anchoredPosition.y+tipHeight+offset, 0.2f);}});sequence.AppendInterval(0.2f);}sequence.AppendCallback(() =>{group.alpha = 1;obj.transform.SetParent(root);obj.transform.localScale = new Vector3(0, 0, 1);obj.SetActive(true);rect1.anchoredPosition = Vector2.zero;visualTipQueue.Enqueue(obj);tipCount++;var txt = obj.transform.Find("txt").GetComponent<Text>();txt.text = tip;if (tipCount > limitCount){var result = visualTipQueue.Dequeue();tipPool.Release(result);tipCount--;}});sequence.Append(obj.transform.DOScale(Vector3.one, 0.1f));sequence.AppendInterval(0.1f);sequence.OnComplete(() =>{timer = 0f;isOk = true;startTimer = true;});}//初始化对象池void InitTipPool(){tipPool = new ObjectPool<GameObject>(() =>{//创建新对象调用var obj = Instantiate(tipObj, objectPool);obj.SetActive(false);return obj;},(go) =>{//获取对象调用go.SetActive(true);ResetLocal(go.transform);},(go) =>{// 在对象放回池子时调用go.SetActive(false);ResetLocal(go.transform);go.transform.SetParent(objectPool);},(go) =>{Destroy(go); });}//重置本地信息void ResetLocal(Transform trans){trans.localPosition = Vector3.zero;trans.localEulerAngles = Vector3.zero;trans.localScale = Vector3.one;}//清空消息public void ClearAllMsg(){var childCount = root.childCount;for (var i = 0; i < childCount; i++){var child = root.GetChild(i);var group = child.GetComponent<CanvasGroup>();var rectValue = child.GetComponent<RectTransform>();var sequence = DOTween.Sequence();sequence.AppendInterval(0.1f * i);sequence.Append(rectValue.DOAnchorPosY(rectValue.anchoredPosition.y + tipHeight+flyHeight, 0.2f));sequence.Append(group.DOFade(0, 0.1f).OnComplete(() =>{visualTipQueue.Dequeue();tipPool.Release(child.gameObject);tipCount--;}));}}
}
左右切换按钮组
本组件一般出现在查看英雄界面,点击左右两个按钮切换查看按钮的详细信息。在英雄列表中,第一个英雄的左按钮不显示,最后一个英雄的右按钮不显示。
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;public class SwitchCheck : MonoBehaviour
{public Button btn_Left;public Button btn_Right;public Text txt_Check;private int sumCount;private int curIndex;private UnityAction<int> callback;//外部逻辑回调void Start(){curIndex = 0;InitGroup(10, (index) =>{txt_Check.text = $"{index}/{sumCount}";});CheckBtnActive();BindBtnLogic(btn_Left, () =>{var nextIndex = curIndex - 1;if (nextIndex < 0){return;}curIndex = nextIndex;CheckBtnActive();});BindBtnLogic(btn_Right, () =>{var nextIndex = curIndex + 1;if (nextIndex >= sumCount){return;}curIndex = nextIndex;CheckBtnActive();});}public void InitGroup(int _sumCount,UnityAction<int> _callback){sumCount = _sumCount;callback = _callback;}//按钮显隐逻辑private void CheckBtnActive(){if (sumCount <= 1){btn_Left.gameObject.SetActive(false);btn_Right.gameObject.SetActive(false);}else{btn_Left.gameObject.SetActive(curIndex >= 1);btn_Right.gameObject.SetActive(curIndex <= sumCount-2);}var showIndex = curIndex + 1;callback?.Invoke(showIndex);}//绑定按钮点击回调private void BindBtnLogic(Button btn, UnityAction action){btn.onClick.RemoveAllListeners();if (action != null){btn.onClick.AddListener(action);}}
}
帮助说明界面
using System.Text;
using UnityEngine;
using UnityEngine.UI;public class ComDesc : MonoBehaviour
{public Text txt_Title;public Text txt_Desc;public RectTransform content;void Update(){if (Input.GetKeyDown(KeyCode.Space)){SetDesc("帮助", "好好学习,天天向上");}if (Input.GetKeyDown(KeyCode.A)){var str = "好好学习,天天向上";StringBuilder sb = new StringBuilder();for (var i = 1; i < 100; i++){sb.Append(str);}SetDesc("帮助", sb.ToString());}}/// <summary>/// 设置说明描述/// </summary>/// <param name="title">界面标题</param>/// <param name="desc">说明文本</param>public void SetDesc(string title,string desc){txt_Title.text = title;txt_Desc.text = desc;LayoutRebuilder.ForceRebuildLayoutImmediate(content);}
}
跑马灯消息提示
有消息队列缓存,等待队列中所有消息播放完后,提示才消失。
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using TMPro;
using UnityEngine.Events;
using UnityEngine.UI;public class Marquee : MonoBehaviour
{public TMP_Text tmpTxt;public RectTransform maskNode;public CanvasGroup canvasGroup;private float maskWidth;private float unitTime = 0.2f;//计算动画时间自定义标准private Queue<MsgNode> marqueeMsg = new Queue<MsgNode>();private List<int> idList = new List<int>();private bool isPlay;//是否正在播放消息private class MsgNode{public int id;public string msg;public int loopCount;}void Start(){maskWidth = maskNode.rect.width;}// Update is called once per framevoid Update(){if (Input.GetKeyDown(KeyCode.Space)){var id = Random.Range(1,100);var str = $"id:{id}好好学习,天天向上>>";AddMarqueeMsg(id,str,1);}if(marqueeMsg.Count > 0) {if (!isPlay){isPlay = true;tmpTxt.rectTransform.anchoredPosition = Vector2.zero;var data = marqueeMsg.Peek();idList.Remove(data.id);DisplayMarqueeMsg(data.msg,data.loopCount, () =>{marqueeMsg.Dequeue();if (marqueeMsg.Count == 0){canvasGroup.alpha = 0;}isPlay = false;});}}}/// <summary>/// 在跑马灯消息队列中添加消息/// </summary>/// <param name="msgId">消息记录的唯一id</param>/// <param name="msg">消息内容</param>/// <param name="loopCount">循环播放时间</param>public void AddMarqueeMsg(int msgId, string msg, int loopCount){if (idList.Contains(msgId)){Debug.LogError("消息已在预播队列");return;}if (canvasGroup.alpha < 0.95f){canvasGroup.alpha = 1;}idList.Add(msgId);marqueeMsg.Enqueue(new MsgNode{id = msgId,msg = msg,loopCount = loopCount});}/// <summary>/// 跑马灯消息播放/// </summary>/// <param name="msgId">消息记录的唯一id</param>/// <param name="msg">消息内容</param>/// <param name="loopCount">循环播放时间</param>public void DisplayMarqueeMsg(string msg,int loopCount,UnityAction callback){tmpTxt.text = msg;LayoutRebuilder.ForceRebuildLayoutImmediate(tmpTxt.rectTransform);var width = tmpTxt.rectTransform.rect.width+maskWidth;var duration = GetDuration(width);tmpTxt.rectTransform.DOAnchorPosX(-width, duration).SetEase(Ease.Linear).SetLoops(loopCount, LoopType.Restart).OnComplete(() =>{callback?.Invoke();});}//根据消息长度计算动画匀速运行时间private float GetDuration(float width){var offset1 = (int)width / 100;var offset2 = width % 100 == 0 ?0:1;var offset = offset1 + offset2;return offset * unitTime;}
}
相关文章:

Unity 通用UI界面逻辑总结
概述 在游戏开发中,常常会遇到一些通用的界面逻辑,它不论在什么类型的游戏中都会出现。为了避免重复造轮子,本文总结并提供了一些常用UI界面的实现逻辑。希望可以帮助大家快速开发通用界面模块,也可以在次基础上进行扩展修改&…...
Python3 与 VSCode:深度对比分析
Python3 与 VSCode:深度对比分析 引言 Python3 和 Visual Studio Code(VSCode)在软件开发领域扮演着举足轻重的角色。Python3 作为一门强大的编程语言,拥有丰富的库和框架,广泛应用于数据科学、人工智能、网络开发等多个领域。而 VSCode 作为一款轻量级且功能强大的代码…...

第五课:Express框架与RESTful API设计:技术实践与探索
在使用Node.js进行企业应用开发,常用的开发框架Express,其中的中间件、路由配置与参数解析、RESTful API核心技术尤为重要,本文将深入探讨它们在应用开发中的具体使用方法,最后通过Postman来对开发的接口进行测试。 一、Express中…...
Linux 内核自定义协议族开发:从 “No buffer space available“ 错误到解决方案
引言 在 Linux 内核网络协议栈开发中,自定义协议族(Address Family, AF)是实现新型通信协议或扩展内核功能的关键步骤。然而,开发者常因对内核地址族管理机制理解不足,遇到如 insmod: No buffer space available 的错误。本文将以实际案例为基础,深入分析错误根源,并提…...

html-列表标签和表单标签
一、列表标签 表格是用来显示数据的,那么列表就是用来布局的 列表最大的特点就是整齐、整洁、有序,它作为布局会更加自由和方便。 根据使用情景不同,列表可以分为三大类:无序列表、有序列表和自定义列表。 1.无序列表(重…...

HTML-网页介绍
一、网页 1.什么是网页: 网站是指在因特网上根据一定的规则,使用 HTML 等制作的用于展示特定内容相关的网页集合。 网页是网站中的一“页”,通常是 HTML 格式的文件,它要通过浏览器来阅读。 网页是构成网站的基本元素…...

动态ip和静态ip适用于哪个场景?有何区别
在数字化浪潮席卷全球的今天,IP地址作为网络世界的“门牌号”,其重要性不言而喻。然而,面对动态IP与静态IP这两种截然不同的IP分配方式,许多用户往往感到困惑:它们究竟有何区别?又分别适用于哪些场景呢&…...
android13打基础: 保存用户免得下次重新登录逻辑
使用SP来做 创建LoginUser.kt // 登录用户需要Email data class LoginUser(val email: String,val password: String, )创建假数据FakeLoginUser.kt object FakeLoginUser {val fake_login_user_items arrayListOf(LoginUser(email "1690544550qq.com",password …...
Linux 4.4 内核源码的目录结构及其主要内容的介绍
以下是 Linux 4.4 内核源码的目录结构及其主要内容的介绍,适用于理解内核模块和驱动开发的基本框架: Linux 4.4 内核源码目录结构 目录作用与内容arch/平台架构相关代码每个子目录对应一种 CPU 架构(如 x86/、arm/、arm64/),包含硬件相关的启动逻辑、中断处理、内存管理等…...
手脑革命:拆解Manus AI如何用“执行智能体”重构生产力——中国团队突破硅谷未竟的技术深水区
第一章:Manus AI 的技术演进与行业背景 1.1 从工具到智能体:AI 技术的范式跃迁 人工智能的发展经历了从规则驱动(Rule-based)到统计学习(Statistical Learning),再到深度学习(Deep…...

Android 调用c++报错 exception of type std::bad_alloc: std::bad_alloc
一、报错信息 terminating with uncaught exception of type std::bad_alloc: std::bad_alloc 查了那部分报错c++代码 szGridSize因为文件太大,初始化溢出了 pEGM->pData = new float[szGridSize]; 解决办法 直接抛出异常,文件太大就失败吧 最后还增加一个日志输出,给…...

匿名GitHub链接使用教程(Anonymous GitHub)2025
Anonymous GitHub 1. 引言2. 准备3. 进入Anonymous GitHub官网4. 用GitHub登录匿名GitHub并授权5. 进入个人中心,然后点击• Anonymize Repo实例化6. 输入你的GitHub链接7. 填写匿名链接的基础信息8. 提交9. 实例化对应匿名GitHub链接10. 进入个人中心管理项目11. 查…...
【0基础跟AI学软考高项】成本管理
💰「成本管理」是什么? 一句话解释:像家庭装修控制预算,既要买得起好材料,又要避免超支吃泡面——成本管理就是精准算钱、合理花钱、动态盯钱,保证项目不破产! 🌋 真实案例…...
模型的原始输出为什么叫 logits
模型的原始输出为什么叫 logits flyfish 一、Logarithm(对数 log) 定义:对数是指数运算的逆运算,表示某个数在某个底数下的指数。 公式:若 b x a b^x a bxa,则 log b ( a ) x \log_b(a) x logb…...

[SAP MM] 查看物料主数据的物料类型
创建物料主数据时,必须为物料分配物料类型,如原材料或半成品 在标准系统中,物料类型ROH(原材料)的所有物料都要从外部采购,而类型为NLAG(非库存物料)的物料则可从外部采购也可在内部生产 ① 特殊物料类型:NLAG 该物料…...
风控模型算法面试题集结
特征处理 1. 特征工程的一般步骤什么?什么是特征迭代 特征工程一般包含: 数据获取,分析数据的可用性(覆盖率,准确率,获取容易程度)数据探索,分析数据业务含义,对特征有一个大致了解,同时进行数据质量校验,包含缺失值、异常值和一致性等;特征处理,包含数据处理和…...

PX4中的DroneCAN的实现库Libuavcan及基础功能示例
简介 Libuavcan是一个用C编写的可移植的跨平台库,对C标准库的依赖小。它可以由几乎任何符合标准的C编译器编译,并且可以在几乎任何体系结构/OS上使用。 在 DroneCAN 中,Libuavcan 有一个 DSDL 编译器,将 DSDL 文件转换为 hpp 头…...

Hot 3D 人体姿态估计 HPE Demo复现过程
视频讲解 Hot 3D 人体姿态估计 HPE Demo复现过程 标题:Hourglass Tokenizer for Efficient Transformer-Based 3D Human Pose Estimation论文地址:https://arxiv.org/abs/2311.12028代码地址:https://github.com/NationalGAILab/HoT 使用con…...

Linux操作系统6- 线程1(线程基础,调用接口,线程优缺点)
上篇文章:Linux操作系统5- 补充知识(可重入函数,volatile关键字,SIGCHLD信号)-CSDN博客 本篇Gitee仓库:myLerningCode/l27 橘子真甜/Linux操作系统与网络编程学习 - 码云 - 开源中国 (gitee.com) 目录 一.…...
每周一个网络安全相关工具——MetaSpLoit
一、Metasploit简介 Metasploit(MSF)是一款开源渗透测试框架,集成了漏洞利用、Payload生成、后渗透模块等功能,支持多种操作系统和硬件平台。其模块化设计(如exploits、auxiliary、payloads等)使其成为全球…...

练习(含atoi的模拟实现,自定义类型等练习)
一、结构体大小的计算及位段 (结构体大小计算及位段 详解请看:自定义类型:结构体进阶-CSDN博客) 1.在32位系统环境,编译选项为4字节对齐,那么sizeof(A)和sizeof(B)是多少? #pragma pack(4)st…...
线程同步:确保多线程程序的安全与高效!
全文目录: 开篇语前序前言第一部分:线程同步的概念与问题1.1 线程同步的概念1.2 线程同步的问题1.3 线程同步的解决方案 第二部分:synchronized关键字的使用2.1 使用 synchronized修饰方法2.2 使用 synchronized修饰代码块 第三部分ÿ…...
java调用dll出现unsatisfiedLinkError以及JNA和JNI的区别
UnsatisfiedLinkError 在对接硬件设备中,我们会遇到使用 java 调用 dll文件 的情况,此时大概率出现UnsatisfiedLinkError链接错误,原因可能有如下几种 类名错误包名错误方法名参数错误使用 JNI 协议调用,结果 dll 未实现 JNI 协…...

LeetCode - 394. 字符串解码
题目 394. 字符串解码 - 力扣(LeetCode) 思路 使用两个栈:一个存储重复次数,一个存储字符串 遍历输入字符串: 数字处理:遇到数字时,累积计算重复次数左括号处理:保存当前状态&a…...

CentOS下的分布式内存计算Spark环境部署
一、Spark 核心架构与应用场景 1.1 分布式计算引擎的核心优势 Spark 是基于内存的分布式计算框架,相比 MapReduce 具有以下核心优势: 内存计算:数据可常驻内存,迭代计算性能提升 10-100 倍(文档段落:3-79…...

【项目实战】通过多模态+LangGraph实现PPT生成助手
PPT自动生成系统 基于LangGraph的PPT自动生成系统,可以将Markdown文档自动转换为PPT演示文稿。 功能特点 Markdown解析:自动解析Markdown文档结构PPT模板分析:分析PPT模板的布局和风格智能布局决策:匹配内容与合适的PPT布局自动…...

现代密码学 | 椭圆曲线密码学—附py代码
Elliptic Curve Cryptography 椭圆曲线密码学(ECC)是一种基于有限域上椭圆曲线数学特性的公钥加密技术。其核心原理涉及椭圆曲线的代数性质、离散对数问题以及有限域上的运算。 椭圆曲线密码学是多种数字签名算法的基础,例如椭圆曲线数字签…...
Spring AI 入门:Java 开发者的生成式 AI 实践之路
一、Spring AI 简介 在人工智能技术快速迭代的今天,Spring AI 作为 Spring 生态系统的新生力量,正在成为 Java 开发者拥抱生成式 AI 的最佳选择。该框架通过模块化设计实现了与主流 AI 服务(如 OpenAI、Anthropic)的无缝对接&…...

NLP学习路线图(二十三):长短期记忆网络(LSTM)
在自然语言处理(NLP)领域,我们时刻面临着处理序列数据的核心挑战。无论是理解句子的结构、分析文本的情感,还是实现语言的翻译,都需要模型能够捕捉词语之间依时序产生的复杂依赖关系。传统的神经网络结构在处理这种序列依赖时显得力不从心,而循环神经网络(RNN) 曾被视为…...

Android 之 kotlin 语言学习笔记三(Kotlin-Java 互操作)
参考官方文档:https://developer.android.google.cn/kotlin/interop?hlzh-cn 一、Java(供 Kotlin 使用) 1、不得使用硬关键字 不要使用 Kotlin 的任何硬关键字作为方法的名称 或字段。允许使用 Kotlin 的软关键字、修饰符关键字和特殊标识…...