当前位置: 首页 > news >正文

Unity实现按键设置功能代码

一、前言

最近在学习unity2D,想做一个横版过关游戏,需要按键设置功能,让用户可以自定义方向键与攻击键等。

自己写了一个,总结如下。

二、界面效果图

在这里插入图片描述
这个是一个csv文件,准备第一列是中文按键说明,第二列是英文,第三列是日文(还没有翻译);第四列是默认按键名称,第五列是默认按键ascII码(如果用户选了恢复默认设置,就会用到);第六列是用户自己设置的按键名称,第七列是用户自己设置的按键ascII码;第八列保留,暂未使用。

在这里插入图片描述
这个是首页,如果选到了这个按钮,就是按键设置页面。

在这里插入图片描述

这个是按键设置页面,实现了按 上下/用户设置的上下移动光标,按回车/ 开始键确定,然后按另一个键进行按键修改。
(图中灰色块就是光标,还没有找图片;最后3行按钮进行了特殊处理)

三、主要部分代码

unity代码比较多,总结下主要用到的3个类。

1.FileManager.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEngine.SceneManagement;
using System.Text;public class FileManager : MonoSingleTon<FileManager>
{private bool isInit =false;public TextAsset keyConfigCsv;//012列是语言,3是默认名称,4是默认ascii,56是用户设置的//这个要装第二行的数据/*wsadjkliqeuocvjk*///语言,这个不能修改,只能读取public static string[] LanguageWasd = new string[16];private static string[] LanguageWasd0 = new string[16];private static string[] LanguageWasd1 = new string[16];private static string[] LanguageWasd2 = new string[16];//默认的key的str与int,这个不能修改,只能读取public static int[] DefaultWasdNumKeys = new int[16];public static string[] DefaultWasdNumKeysStr = new string[16];//实际用的key的str与intpublic static int[] WasdNumKeys = new int[16];public static string[] WasdNumKeysStr = new string[16];//临时用的key的str与int,因为可能只修改不保存,所以用public static int[] WasdNumKeysTemp = new int[16];public static string[] WasdNumKeysStrTemp = new string[16];// Start is called before the first frame update// 这个方法会在脚本被启用时注册监听事件void OnEnable(){//Debug.Log("进入这个场景playerData");//Debug.Log("执行完毕这个场景playerData");}private void Awake(){if (!isInit){InitKeyConfig();}}void Start(){}// Update is called once per framevoid Update(){}private bool InitKeyConfig(){string path = GetKeyConfigPath();Debug.Log(path);if (File.Exists(path)){//用用户的初始化LoadKeyConfig(File.ReadAllText(path).Split("\n"));Debug.Log("使用用户的初始化");isInit = true;return false;}else{string text = keyConfigCsv.text;//把默认的文件写进本地File.WriteAllText(path, text, Encoding.UTF8);//用默认的初始化LoadKeyConfig(text.Split("\n"));//string[] dataRow = text.Split("\n");//File.WriteAllLines(path, dataRow);Debug.Log("使用默认的初始化");isInit = true;return true;}}//读取到临时变量里public void LoadKeyConfig(string[] dataRow){int language = LanguageManager.GetLanguage();//File.WriteAllLines(path, dataRow);for(int i = 0; i < dataRow.Length; i++){string[] dataCell = dataRow[i].Split(",");if (i >= 16){break;}else{LanguageWasd[i] = dataCell[language];LanguageWasd0[i] = dataCell[0];LanguageWasd1[i] = dataCell[1];LanguageWasd2[i] = dataCell[2];DefaultWasdNumKeysStr[i] = dataCell[3];DefaultWasdNumKeys[i] = int.Parse(dataCell[4]);WasdNumKeysStr[i] = dataCell[5];WasdNumKeysStrTemp[i] = dataCell[5];WasdNumKeys[i] = int.Parse(dataCell[6]);WasdNumKeysTemp[i] = int.Parse(dataCell[6]);}}}private static void SaveKeyConfig(string[] dataRow){//Application.dataPath//这个打包后就不能用了,可能没权限string path = GetKeyConfigPath();if (File.Exists(path)){//删了重新创建File.Delete(path);File.CreateText(path).Close();}else{File.CreateText(path).Close();}//List<string> datas2 = new List<string>();//datas.Add("coins,1");Debug.Log("写入数据");File.WriteAllLines(path, dataRow, Encoding.UTF8);Debug.Log("写入数据完毕");}public void ResetKeyConfig(){string text = keyConfigCsv.text;//用默认的初始化LoadKeyConfig(text.Split("\n"));//并且保存SaveKeyConfig(text.Split("\n"));//SceneManager.LoadScene(0);}public static string GetKeyConfigPath(){return Application.persistentDataPath + "/KeyConfig.csv";}public static void SaveKeyConfig(){string[] newData = new string[16];//保存文件for(int i=0; i<16; i++){newData[i] = LanguageWasd0[i] + "," + LanguageWasd1[i] + "," + LanguageWasd2[i] + ","+ DefaultWasdNumKeysStr[i] + "," + DefaultWasdNumKeys[i] + "," + WasdNumKeysStr[i] + "," + WasdNumKeys[i] + "," + ";";}SaveKeyConfig(newData);Debug.Log("保存键盘信息完毕");}}

这个类负责操作配置文件,要把内置的配置文件保存到本地配置文件中,以及读取配置文件。(要区分读取内置的还是本地的)

2.TitleScreen.cs

using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;public class TitleScreen : MonoBehaviour
{TextMeshProUGUI tmpTitleText;bool calledNextScene;bool inputDetected = false;bool isTitle = true;bool isKeySetting = false;bool isLanguageSetting = false;int alphaKeyPressText = 255;bool alphaKeyPressTextShow = true;public AudioClip keyPressClip;public AudioClip keyChangeClip;[SerializeField] Image[] buttons = new Image[5];[SerializeField] Text[] buttonsText = new Text[5];private int buttonsChoosedNum = 0;private enum TitleScreenStates { WaitForInput, NextScene };TitleScreenStates titleScreenState = TitleScreenStates.WaitForInput;#if UNITY_STANDALONEstring insertKeyPressText = "PRESS ANY KEY";
#endif#if UNITY_ANDROID || UNITY_IOSstring insertKeyPressText = "TAP TO START";
#endifstring titleText =
@"<size=18><color=#ffffff{0:X2}>{1}</color></size>";private void Awake(){//tmpTitleText = GameObject.Find("TitleText").GetComponent<TextMeshProUGUI>();}// Start is called before the first frame updatevoid Start(){//tmpTitleText.alignment = TextAlignmentOptions.Center;//tmpTitleText.alignment = TextAlignmentOptions.Midline;//tmpTitleText.fontStyle = FontStyles.UpperCase;titleScreenState = TitleScreenStates.WaitForInput;if (isHaveSavePoint()){initButton(1);}else {initButton(0);}}// Update is called once per framevoid Update(){switch(titleScreenState){case TitleScreenStates.WaitForInput://buttonsText[buttonsChoosedNum].text = String.Format(titleText, alphaKeyPressText, buttonsText[buttonsChoosedNum].text);buttonsText[buttonsChoosedNum].enabled = alphaKeyPressTextShow;if (!inputDetected){ChooseButton();SelectButton();}break;case TitleScreenStates.NextScene:if (!calledNextScene){GameManager.Instance.StartNextScene();calledNextScene = true;}break;}}private IEnumerator FlashTitleText() { for(int i = 0; i < 5; i++){alphaKeyPressTextShow = true;alphaKeyPressText = 0;yield return new WaitForSeconds(0.1f);alphaKeyPressTextShow = false;alphaKeyPressText = 255;yield return new WaitForSeconds(0.1f);}alphaKeyPressTextShow = true;alphaKeyPressText = 0;yield return new WaitForSeconds(0.1f);titleScreenState = TitleScreenStates.NextScene;}private IEnumerator FlashTitleTextAndOpenKeyConfig(){for (int i = 0; i < 5; i++){alphaKeyPressTextShow = true;alphaKeyPressText = 0;yield return new WaitForSeconds(0.1f);alphaKeyPressTextShow = false;alphaKeyPressText = 255;yield return new WaitForSeconds(0.1f);}alphaKeyPressTextShow = true;alphaKeyPressText = 0;yield return new WaitForSeconds(0.1f);//退出的时候,需要改为接受输入KeyConfigScript.Instance.Show(() => { inputDetected = false;Debug.Log("回调方法"); });}private bool isHaveSavePoint() {return false;}private void ChooseButton() {if (  Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown((KeyCode)FileManager.WasdNumKeys[0])  ){if (buttonsChoosedNum > 0){buttons[buttonsChoosedNum].enabled = false;buttonsChoosedNum--;buttons[buttonsChoosedNum].enabled = true;PlayChangeButton();}else{PlayChangeButton();}}if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown((KeyCode)FileManager.WasdNumKeys[1]) ){if (buttonsChoosedNum < buttons.Length - 1){buttons[buttonsChoosedNum].enabled = false;buttonsChoosedNum++;buttons[buttonsChoosedNum].enabled = true;PlayChangeButton();}else{PlayChangeButton();}}}private void SelectButton() { if( Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown((KeyCode)FileManager.WasdNumKeys[13])  ){if (buttonsChoosedNum == 0){inputDetected = true;StartCoroutine(FlashTitleText());SoundManager.Instance.Play(keyPressClip);} else if (buttonsChoosedNum == 1) {inputDetected = true;SoundManager.Instance.Play(keyPressClip);}else if (buttonsChoosedNum == 2){inputDetected = true;SoundManager.Instance.Play(keyPressClip);}else if (buttonsChoosedNum == 3){inputDetected = true;SoundManager.Instance.Play(keyPressClip);StartCoroutine(FlashTitleTextAndOpenKeyConfig());}else if (buttonsChoosedNum == 4){Application.Quit();}}}private void PlayChangeButton() { if(keyChangeClip != null){SoundManager.Instance.Play(keyChangeClip);}}private void initButton(int n) {buttonsChoosedNum = n;for(int i = 0; i < buttons.Length; i++){if (i == n){buttons[i].enabled = true;}else {buttons[i].enabled = false;}}}}

这个是游戏首页用的类,主要管是否显示按键设置页面;
按键设置页面也在首页,是个Canvas对象,刚开始会隐藏,选择按键设置按钮并确定后,才会展示。

3.KeyConfigScript.cs

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;public class KeyConfigScript : MonoBehaviour
{bool flashText = false;public static KeyConfigScript Instance = null;[SerializeField] Canvas canvas;public AudioClip keyChangeClip;public AudioClip keySelectClip;/*wsadjkliqeuocvjk*/public UnityEngine.UI.Image[] buttons = new UnityEngine.UI.Image[19];[SerializeField] Text[] buttonsText = new Text[19];[SerializeField] ScrollRect scrollRect;private Action nowScreenAction;private int buttonsChoosedNum = 0;bool alphaKeyPressTextShow = true;//检测按键bool canInput = false;bool canMove = true;private void Awake(){// If there is not already an instance of SoundManager, set it to this.if (Instance == null){Instance = this;}//If an instance already exists, destroy whatever this object is to enforce the singleton.else if (Instance != this){Destroy(gameObject);}//Set SoundManager to DontDestroyOnLoad so that it won't be destroyed when reloading our scene.DontDestroyOnLoad(gameObject);//默认隐藏Close();}private void OnEnable(){}private void initKeysObjects() {//读取下当前配置文件,获得每个按键配置的名称和值for (int i = 0; i < buttons.Length; i++){if (i >= 16){buttons[i].enabled = false;}else{buttonsText[i].text = FileManager.LanguageWasd[i] + ":" + FileManager.WasdNumKeysStr[i];//初始化方法,只有0才是if (i == 0){buttons[i].enabled = true;}else{buttons[i].enabled = false;}}}}private void ChooseButton(){if ( Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown((KeyCode)FileManager.WasdNumKeys[0]) ){if (buttonsChoosedNum > 0){buttons[buttonsChoosedNum].enabled = false;buttonsChoosedNum--;buttons[buttonsChoosedNum].enabled = true;PlayChangeButton();ScrollUpOrDown(buttonsChoosedNum, false);}else{//移动到最后一个buttons[buttonsChoosedNum].enabled = false;buttonsChoosedNum = buttons.Length - 1;buttons[buttonsChoosedNum].enabled = true;PlayChangeButton();}}if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown((KeyCode)FileManager.WasdNumKeys[1]) ){if (buttonsChoosedNum < buttons.Length - 1){buttons[buttonsChoosedNum].enabled = false;buttonsChoosedNum++;buttons[buttonsChoosedNum].enabled = true;PlayChangeButton();ScrollUpOrDown(buttonsChoosedNum, true);}else{//移动到第一个buttons[buttonsChoosedNum].enabled = false;buttonsChoosedNum = 0;buttons[buttonsChoosedNum].enabled = true;PlayChangeButton();}}}private void SelectButton(){//如果是可以移动状态if (canMove){//如果按下选择键if (  Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown((KeyCode)FileManager.WasdNumKeys[13])  ) {//播放声音PlaySelectButton();//关闭移动canMove = false;//如果是这些键,特殊处理然后返回switch (buttonsChoosedNum){case 16:StartCoroutine(FlashTitleTextSecond(Reset));return;case 17:StartCoroutine(FlashTitleTextSecond(SaveAndClose));return;case 18:StartCoroutine(FlashTitleTextSecond(Close));return;}//如果是普通键//闪烁标志位打开flashText = true;//字幕闪烁StartCoroutine(FlashTitleText());}}else{BeforeSettingKey();}}private void BeforeSettingKey(){if (Input.anyKeyDown){//需要看这个键能不能设置bool canSetting = false;foreach (KeyCode key in System.Enum.GetValues(typeof(KeyCode))){if (Input.GetKeyDown(key)){// 检查按键是否为可打印字符if ((key >= KeyCode.A && key <= KeyCode.Z) || (key >= KeyCode.Alpha0 && key <= KeyCode.Alpha9)){// 将字符转换为 ASCII 码string keyStr = key.ToString();//char keyChar = keyStr[0];int asciiValue = (int)key;Debug.Log($"按下的键 {key} 对应的 ASCII 码值是:{asciiValue}");SettingKey(keyStr, asciiValue);canSetting = true;break;}else{// 非字母数字键(你可以根据需求处理这些按键)Debug.Log($"按下了非字符键:{key}");if (key == KeyCode.Space){SettingKey("Space", 32);canSetting = true;break;}else if (key == KeyCode.Return){SettingKey("Enter", 13);canSetting = true;break;}else if (key == KeyCode.UpArrow){SettingKey("Up", 273);canSetting = true;break;}else if (key == KeyCode.DownArrow){SettingKey("Down", 274);canSetting = true;break;}else if (key == KeyCode.LeftArrow){SettingKey("Left", 276);canSetting = true;break;}else if (key == KeyCode.RightArrow){SettingKey("Right", 275);canSetting = true;break;}}}}//如果可以设置,再进行后续操作if (canSetting){//停止闪烁StartCoroutine(ResetTitleText());}}}private void SettingKey(string str, int ascII){//更新设置的信息FileManager.WasdNumKeysStrTemp[buttonsChoosedNum] = str;FileManager.WasdNumKeysTemp[buttonsChoosedNum] = ascII;//更新按键文本信息buttonsText[buttonsChoosedNum].text = FileManager.LanguageWasd[buttonsChoosedNum] + ":"+ str;}private IEnumerator FlashTitleText(){while (flashText) { alphaKeyPressTextShow = true;yield return new WaitForSeconds(0.1f);alphaKeyPressTextShow = false;yield return new WaitForSeconds(0.1f);}}private IEnumerator FlashTitleTextSecond(Func<bool> func){for (int i=0; i<5; i++){alphaKeyPressTextShow = true;yield return new WaitForSeconds(0.1f);alphaKeyPressTextShow = false;yield return new WaitForSeconds(0.1f);}alphaKeyPressTextShow = true;yield return new WaitForSeconds(0.1f);//闪烁完毕后才能移动canMove = true;//闪烁完毕后执行func();}private IEnumerator ResetTitleText(){flashText = false;yield return new WaitForSeconds(0.2f);alphaKeyPressTextShow = true;buttonsText[buttonsChoosedNum].enabled = true;canMove = true;}private void PlayChangeButton(){if (keyChangeClip != null){SoundManager.Instance.Play(keyChangeClip);}}private void PlaySelectButton(){if (keySelectClip != null){SoundManager.Instance.Play(keySelectClip);}}//先从配置文件读取配置信息void Start(){}// Update is called once per framevoid Update(){if (canInput){buttonsText[buttonsChoosedNum].enabled = alphaKeyPressTextShow;if (canMove){ChooseButton();}SelectButton();}}//翻页,现在不用private void ScrollUpOrDown(int count, bool isDown){/*if(count == 8 && isDown){scrollRect.normalizedPosition = new Vector2(0, 0);}else if (count == 7 && !isDown) {scrollRect.normalizedPosition = new Vector2(0, 1);}*/}public void Show(Action action) {//翻页,现在不用//scrollRect.normalizedPosition = new Vector2(0, 0);alphaKeyPressTextShow = true;buttonsChoosedNum = 0;initKeysObjects();this.nowScreenAction = action;Debug.Log("show Key Config");canvas.enabled = true;canInput = true;}private bool Reset(){for (int i = 0; i < 16; i++){//先把text内容改了buttonsText[i].text = FileManager.LanguageWasd[i] + ":" + FileManager.DefaultWasdNumKeysStr[i];//然后把临时数组改了FileManager.WasdNumKeysStrTemp[i] = FileManager.DefaultWasdNumKeysStr[i];FileManager.WasdNumKeysTemp[i] = FileManager.DefaultWasdNumKeys[i];}return true;}private bool Save(){for (int i = 0; i < 16; i++){//给实际用的赋值FileManager.WasdNumKeysStr[i] = FileManager.WasdNumKeysStrTemp[i];FileManager.WasdNumKeys[i] = FileManager.WasdNumKeysTemp[i];}//写入文件FileManager.SaveKeyConfig();return true;}private bool SaveAndClose(){Save();Close();return true;}public bool Close() {canvas.enabled = false;canInput = false;//上一个屏幕,改为接受输入if(nowScreenAction != null){nowScreenAction();}return true;//nowScreenManager.GetComponent<TitleScreen>().inputDetected = false;}}

这个类就是按键设置页面用的类,有光标上下移动功能、按钮选择后让字幕闪烁的功能、再次按键后设置新按键功能。

四、备注

unity代码比较复杂,直接复制粘贴是无法使用的,每人的场景元素也不一样,很多变量会不存在,仅供参考。

以上就是个人编写的设置按键的代码,大致逻辑如下:

1.游戏启动后,先判断有没有本地配置文件,如果有、就读取本地配置文件并初始化;如果没有,就用内置配置文件初始化,并把内置配置文件保存到本地。

2.进入按键选择页面时,上下方向键移动光标,按回车可以选择按键,此时按键闪烁,再按另一个键可以设置为新按键。

3.有恢复默认设置功能,有保存并退出功能,有直接退出功能;如果选保存并退出,才把设置的临时按键数组赋值到实际使用的按键数组,并保存到本地配置文件。

相关文章:

Unity实现按键设置功能代码

一、前言 最近在学习unity2D&#xff0c;想做一个横版过关游戏&#xff0c;需要按键设置功能&#xff0c;让用户可以自定义方向键与攻击键等。 自己写了一个&#xff0c;总结如下。 二、界面效果图 这个是一个csv文件&#xff0c;准备第一列是中文按键说明&#xff0c;第二列…...

基于物联网技术的实时数据流可视化研究(论文+源码)

1系统方案设计 根据系统功能的设计要求&#xff0c;展开基于物联网技术的实时数据流可视化研究设计。如图2.1所示为系统总体设计框图&#xff0c;系统以STM32单片机做为主控制器&#xff0c;通过DHT11、MQ-2、光照传感器实现环境中温湿度、烟雾、光照强度数据的实时检测&#x…...

list容器(详解)

1. list的介绍及使用 1.1 list的介绍&#xff08;双向循环链表&#xff09; https://cplusplus.com/reference/list/list/?kwlist&#xff08;list文档介绍&#xff09; 1. list是可以在常数范围内在任意位置进行插入和删除的序列式容器&#xff0c;并且该容器可以前后双向迭…...

Elasticsearch基本使用详解

文章目录 Elasticsearch基本使用详解一、引言二、环境搭建1、安装 Elasticsearch2、安装 Kibana&#xff08;可选&#xff09; 三、索引操作1、创建索引2、查看索引3、删除索引 四、数据操作1、插入数据2、查询数据&#xff08;1&#xff09;简单查询&#xff08;2&#xff09;…...

17.3.4 颜色矩阵

版权声明&#xff1a;本文为博主原创文章&#xff0c;转载请在显著位置标明本文出处以及作者网名&#xff0c;未经作者允许不得用于商业目的。 17.3.4.1 矩阵基本概念 矩阵&#xff08;Matrix&#xff09;是一个按照长方阵列排列的复数或实数集合&#xff0c;类似于数组。 由…...

FPGA 时钟多路复用

时钟多路复用 您可以使用并行和级联 BUFGCTRL 的组合构建时钟多路复用器。布局器基于时钟缓存 site 位置可用性查找最佳布局。 如果可能&#xff0c;布局器将 BUFGCTRL 布局在相邻 site 位置中以利用专用级联路径。如无法实现&#xff0c;则布局器将尝试将 BUFGCTRL 从…...

机器学习10

自定义数据集 使用scikit-learn中svm的包实现svm分类 代码 import numpy as np import matplotlib.pyplot as pltclass1_points np.array([[1.9, 1.2],[1.5, 2.1],[1.9, 0.5],[1.5, 0.9],[0.9, 1.2],[1.1, 1.7],[1.4, 1.1]])class2_points np.array([[3.2, 3.2],[3.7, 2.9],…...

【Block总结】CoT,上下文Transformer注意力|即插即用

一. 论文信息 标题: Contextual Transformer Networks for Visual Recognition论文链接: arXivGitHub链接: https://github.com/JDAI-CV/CoTNet 二. 创新点 上下文Transformer模块&#xff08;CoT&#xff09;: 提出了CoT模块&#xff0c;能够有效利用输入键之间的上下文信息…...

linux库函数 gettimeofday() localtime的概念和使用案例

在Linux系统中&#xff0c;gettimeofday() 和 localtime() 是两个常用的时间处理函数&#xff0c;分别用于获取高精度时间戳和将时间戳转换为本地时间。以下是它们的概念和使用案例的详细说明&#xff1a; 1. gettimeofday() 函数 概念 功能&#xff1a;获取当前时间&#xf…...

编程题-电话号码的字母组合(中等)

题目&#xff1a; 给定一个仅包含数字 2-9 的字符串&#xff0c;返回所有它能表示的字母组合。答案可以按 任意顺序 返回。 给出数字到字母的映射如下&#xff08;与电话按键相同&#xff09;。注意 1 不对应任何字母。 解法一&#xff08;哈希表动态添加&#xff09;&#x…...

EasyExcel使用详解

文章目录 EasyExcel使用详解一、引言二、环境准备与基础配置1、添加依赖2、定义实体类 三、Excel 读取详解1、基础读取2、自定义监听器3、多 Sheet 处理 四、Excel 写入详解1、基础写入2、动态列与复杂表头3、样式与模板填充 五、总结 EasyExcel使用详解 一、引言 EasyExcel 是…...

基于“蘑菇书”的强化学习知识点(二):强化学习中基于策略(Policy-Based)和基于价值(Value-Based)方法的区别

强化学习中基于策略&#xff08;Policy-Based&#xff09;和基于价值&#xff08;Value-Based&#xff09;方法的区别 摘要强化学习中基于策略&#xff08;Policy-Based&#xff09;和基于价值&#xff08;Value-Based&#xff09;方法的区别1. 定义与核心思想(1) 基于策略的方…...

民法学学习笔记(个人向) Part.2

民法学学习笔记(个人向) Part.2 民法始终在解决两个生活中的核心问题&#xff1a; 私法自治&#xff1b;交易安全&#xff1b; 3. 自然人 3.4 个体工商户、农村承包经营户 都是特殊的个体经济单位&#xff1b; 3.4.1 个体工商户 是指在法律的允许范围内&#xff0c;依法经…...

物业管理系统源码驱动社区管理革新提升用户满意度与服务效率

内容概要 在当今社会&#xff0c;物业管理正面临着前所未有的挑战&#xff0c;尤其是在社区管理方面。人们对社区安全、环境卫生、设施维护等日常生活需求愈发重视&#xff0c;物业公司必须提升服务质量&#xff0c;以满足居民日益增长的期望。而物业管理系统源码的出现&#…...

租房管理系统助力数字化转型提升租赁服务质量与用户体验

内容概要 随着信息技术的快速发展&#xff0c;租房管理系统正逐渐成为租赁行业数字化转型的核心工具。通过全面集成资产管理、租赁管理和物业管理等功能&#xff0c;这种系统力求为用户提供高效便捷的服务体验。无论是工业园、产业园还是写字楼、公寓&#xff0c;租房管理系统…...

Ollama教程:轻松上手本地大语言模型部署

Ollama教程&#xff1a;轻松上手本地大语言模型部署 在大语言模型&#xff08;LLM&#xff09;飞速发展的今天&#xff0c;越来越多的开发者希望能够在本地部署和使用这些模型&#xff0c;以便更好地控制数据隐私和计算资源。Ollama作为一个开源工具&#xff0c;旨在简化大语言…...

Baklib推动数字化内容管理解决方案助力企业数字化转型

内容概要 在当今信息爆炸的时代&#xff0c;数字化内容管理成为企业提升效率和竞争力的关键。企业在面对大量数据时&#xff0c;如何高效地存储、分类与检索信息&#xff0c;直接关系到其经营的成败。数字化内容管理不仅限于简单的文档存储&#xff0c;更是整合了文档、图像、…...

DeepSeek-R1 论文. Reinforcement Learning 通过强化学习激励大型语言模型的推理能力

论文链接&#xff1a; [2501.12948] DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning 实在太长&#xff0c;自行扔到 Model 里&#xff0c;去翻译去提问吧。 工作原理&#xff1a; 主要技术&#xff0c;就是训练出一些专有用途小模型&…...

DOM 操作入门:HTML 元素操作与页面事件处理

DOM 操作入门:HTML 元素操作与页面事件处理 DOM 操作入门:HTML 元素操作与页面事件处理什么是 DOM?1. 如何操作 HTML 元素?1.1 使用 `document.getElementById()` 获取单个元素1.2 使用 `document.querySelector()` 和 `document.querySelectorAll()` 获取多个元素1.3 创建…...

使用 HTTP::Server::Simple 实现轻量级 HTTP 服务器

在Perl中&#xff0c;HTTP::Server::Simple 模块提供了一种轻量级的方式来实现HTTP服务器。该模块简单易用&#xff0c;适合快速开发和测试HTTP服务。本文将详细介绍如何使用 HTTP::Server::Simple 模块创建和配置一个轻量级HTTP服务器。 安装 HTTP::Server::Simple 首先&…...

国防科技大学计算机基础课程笔记02信息编码

1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制&#xff0c;因此这个了16进制的数据既可以翻译成为这个机器码&#xff0c;也可以翻译成为这个国标码&#xff0c;所以这个时候很容易会出现这个歧义的情况&#xff1b; 因此&#xff0c;我们的这个国…...

TDengine 快速体验(Docker 镜像方式)

简介 TDengine 可以通过安装包、Docker 镜像 及云服务快速体验 TDengine 的功能&#xff0c;本节首先介绍如何通过 Docker 快速体验 TDengine&#xff0c;然后介绍如何在 Docker 环境下体验 TDengine 的写入和查询功能。如果你不熟悉 Docker&#xff0c;请使用 安装包的方式快…...

树莓派超全系列教程文档--(62)使用rpicam-app通过网络流式传输视频

使用rpicam-app通过网络流式传输视频 使用 rpicam-app 通过网络流式传输视频UDPTCPRTSPlibavGStreamerRTPlibcamerasrc GStreamer 元素 文章来源&#xff1a; http://raspberry.dns8844.cn/documentation 原文网址 使用 rpicam-app 通过网络流式传输视频 本节介绍来自 rpica…...

STM32+rt-thread判断是否联网

一、根据NETDEV_FLAG_INTERNET_UP位判断 static bool is_conncected(void) {struct netdev *dev RT_NULL;dev netdev_get_first_by_flags(NETDEV_FLAG_INTERNET_UP);if (dev RT_NULL){printf("wait netdev internet up...");return false;}else{printf("loc…...

【机器视觉】单目测距——运动结构恢复

ps&#xff1a;图是随便找的&#xff0c;为了凑个封面 前言 在前面对光流法进行进一步改进&#xff0c;希望将2D光流推广至3D场景流时&#xff0c;发现2D转3D过程中存在尺度歧义问题&#xff0c;需要补全摄像头拍摄图像中缺失的深度信息&#xff0c;否则解空间不收敛&#xf…...

MVC 数据库

MVC 数据库 引言 在软件开发领域,Model-View-Controller(MVC)是一种流行的软件架构模式,它将应用程序分为三个核心组件:模型(Model)、视图(View)和控制器(Controller)。这种模式有助于提高代码的可维护性和可扩展性。本文将深入探讨MVC架构与数据库之间的关系,以…...

vue3+vite项目中使用.env文件环境变量方法

vue3vite项目中使用.env文件环境变量方法 .env文件作用命名规则常用的配置项示例使用方法注意事项在vite.config.js文件中读取环境变量方法 .env文件作用 .env 文件用于定义环境变量&#xff0c;这些变量可以在项目中通过 import.meta.env 进行访问。Vite 会自动加载这些环境变…...

让回归模型不再被异常值“带跑偏“,MSE和Cauchy损失函数在噪声数据环境下的实战对比

在机器学习的回归分析中&#xff0c;损失函数的选择对模型性能具有决定性影响。均方误差&#xff08;MSE&#xff09;作为经典的损失函数&#xff0c;在处理干净数据时表现优异&#xff0c;但在面对包含异常值的噪声数据时&#xff0c;其对大误差的二次惩罚机制往往导致模型参数…...

七、数据库的完整性

七、数据库的完整性 主要内容 7.1 数据库的完整性概述 7.2 实体完整性 7.3 参照完整性 7.4 用户定义的完整性 7.5 触发器 7.6 SQL Server中数据库完整性的实现 7.7 小结 7.1 数据库的完整性概述 数据库完整性的含义 正确性 指数据的合法性 有效性 指数据是否属于所定…...

RabbitMQ入门4.1.0版本(基于java、SpringBoot操作)

RabbitMQ 一、RabbitMQ概述 RabbitMQ RabbitMQ最初由LShift和CohesiveFT于2007年开发&#xff0c;后来由Pivotal Software Inc.&#xff08;现为VMware子公司&#xff09;接管。RabbitMQ 是一个开源的消息代理和队列服务器&#xff0c;用 Erlang 语言编写。广泛应用于各种分布…...