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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/10995.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

稀疏混合专家架构语言模型(MoE)

注&#xff1a;本文为 “稀疏混合专家架构语言模型&#xff08;MoE&#xff09;” 相关文章合辑。 手把手教你&#xff0c;从零开始实现一个稀疏混合专家架构语言模型&#xff08;MoE&#xff09; 机器之心 2024年02月11日 12:21 河南 选自huggingface 机器之心编译 机器之心…

C++哈希(链地址法)(二)详解

文章目录 1.开放地址法1.1key不能取模的问题1.1.1将字符串转为整型1.1.2将日期类转为整型 2.哈希函数2.1乘法散列法&#xff08;了解&#xff09;2.2全域散列法&#xff08;了解&#xff09; 3.处理哈希冲突3.1线性探测&#xff08;挨着找&#xff09;3.2二次探测&#xff08;跳…

29.Word:公司本财年的年度报告【13】

目录 NO1.2.3.4 NO5.6.7​ NO8.9.10​ NO1.2.3.4 另存为F12&#xff1a;考生文件夹&#xff1a;Word.docx选中绿色标记的标题文本→样式对话框→单击右键→点击样式对话框→单击右键→修改→所有脚本→颜色/字体/名称→边框&#xff1a;0.5磅、黑色、单线条&#xff1a;点…

深入理解Java引用传递

先看一段代码&#xff1a; public static void add(String a) {a "new";System.out.println("add: " a); // 输出内容&#xff1a;add: new}public static void main(String[] args) {String a null;add(a);System.out.println("main: " a);…

Python从零构建macOS状态栏应用(仿ollama)并集成AI同款流式聊天 API 服务(含打包为独立应用)

在本教程中,我们将一步步构建一个 macOS 状态栏应用程序,并集成一个 Flask 服务器,提供流式响应的 API 服务。 如果你手中正好持有一台 MacBook Pro,又怀揣着搭建 AI 聊天服务的想法,却不知从何处迈出第一步,那么这篇文章绝对是你的及时雨。 最终,我们将实现以下功能: …

Qt之数据库操作三

主要介绍qt框架中对数据库的增加&#xff0c;删除和修改功能。 软件界面如下 程序结构 tdialogdata.h中代码 #ifndef TDIALOGDATA_H #define TDIALOGDATA_H#include <QDialog> #include<QSqlRecord> namespace Ui { class TDialogData; }class TDialogData : pub…

neo4j入门

文章目录 neo4j版本说明部署安装Mac部署docker部署 neo4j web工具使用数据结构图数据库VS关系数据库 neo4j neo4j官网Neo4j是用ava实现的开源NoSQL图数据库。Neo4作为图数据库中的代表产品&#xff0c;已经在众多的行业项目中进行了应用&#xff0c;如&#xff1a;网络管理&am…

JVM-运行时数据区

JVM的组成 运行时数据区-总览 Java虚拟机在运行Java程序过程中管理的内存区域&#xff0c;称之为运行时数据区。 《Java虚拟机规范》中规定了每一部分的作用 运行时数据区-应用场景 Java的内存分成哪几部分&#xff1f; Java内存中哪些部分会内存溢出&#xff1f; JDK7 和J…

Java篇之继承

目录 一. 继承 1. 为什么需要继承 2. 继承的概念 3. 继承的语法 4. 访问父类成员 4.1 子类中访问父类的成员变量 4.2 子类中访问父类的成员方法 5. super关键字 6. super和this关键字 7. 子类构造方法 8. 代码块的执行顺序 9. protected访问修饰限定符 10. 继承方式…

leetcode——验证二叉搜索树(java)

给你一个二叉树的根节点 root &#xff0c;判断其是否是一个有效的二叉搜索树。 有效 二叉搜索树定义如下&#xff1a; 节点的左子树只包含小于当前节点的数。 节点的右子树只包含 大于 当前节点的数。 所有左子树和右子树自身必须也是二叉搜索树。 示例 1&#xff1a; 输入…

家居EDI:Hom Furniture EDI需求分析

HOM Furniture 是一家成立于1977年的美国家具零售商&#xff0c;总部位于明尼苏达州。公司致力于提供高品质、时尚的家具和家居用品&#xff0c;满足各种家庭和办公需求。HOM Furniture 以广泛的产品线和优质的客户服务在市场上赢得了良好的口碑。公司经营的产品包括卧室、客厅…

Spring Boot + Facade Pattern : 通过统一接口简化多模块业务

文章目录 Pre概述在编程中&#xff0c;外观模式是如何工作的&#xff1f;外观设计模式 UML 类图外观类和子系统的关系优点案例外观模式在复杂业务中的应用实战运用1. 项目搭建与基础配置2. 构建子系统组件航班服务酒店服务旅游套餐服务 3. 创建外观类4. 在 Controller 中使用外…

八、Spring Boot 日志详解

目录 一、日志的用途 二、日志使用 2.1 打印日志 2.1.1 在程序中获取日志对象 2.1.2 使用日志对象打印日志 2.2、日志框架介绍 2.2.1 门面模式(外观模式) 2.2.2 门面模式的实现 2.2.3 SLF4J 框架介绍 2.3 日志格式的说明 2.4 日志级别 2.4.1 日志级别的分类 2.4.2…

创建前端项目的方法

目录 一、创建前端项目的方法 1.前提&#xff1a;安装Vue CLI 2.方式一&#xff1a;vue create项目名称 3.方式二&#xff1a;vue ui 二、Vue项目结构 三、修改Vue项目端口号的方法 一、创建前端项目的方法 1.前提&#xff1a;安装Vue CLI npm i vue/cli -g 2.方式一&…

(leetcode 213 打家劫舍ii)

代码随想录&#xff1a; 将一个线性数组换成两个线性数组&#xff08;去掉头&#xff0c;去掉尾&#xff09; 分别求两个线性数组的最大值 最后求这两个数组的最大值 代码随想录视频 #include<iostream> #include<vector> #include<algorithm> //nums:2,…

【Python】第七弹---Python基础进阶:深入字典操作与文件处理技巧

✨个人主页&#xff1a; 熬夜学编程的小林 &#x1f497;系列专栏&#xff1a; 【C语言详解】 【数据结构详解】【C详解】【Linux系统编程】【MySQL】【Python】 目录 1、字典 1.1、字典是什么 1.2、创建字典 1.3、查找 key 1.4、新增/修改元素 1.5、删除元素 1.6、遍历…

本地部署DeepSeek开源多模态大模型Janus-Pro-7B实操

本地部署DeepSeek开源多模态大模型Janus-Pro-7B实操 Janus-Pro-7B介绍 Janus-Pro-7B 是由 DeepSeek 开发的多模态 AI 模型&#xff0c;它在理解和生成方面取得了显著的进步。这意味着它不仅可以处理文本&#xff0c;还可以处理图像等其他模态的信息。 模型主要特点:Permalink…

BW AO/工作簿权限配置

场景&#xff1a; 按事业部配置工作簿权限&#xff1b; 1、创建用户 事务码&#xff1a;SU01&#xff0c;用户主数据的维护&#xff0c;可以创建、修改、删除、锁定、解锁、修改密码等 用户设置详情页 2、创建权限角色 用户的权限菜单是通过权限角色分配来实现的 2.1、自定…

jstat命令详解

jstat 用于监视虚拟机运行时状态信息的命令&#xff0c;它可以显示出虚拟机进程中的类装载、内存、垃圾收集、JIT 编译等运行数据。 命令的使用格式如下。 jstat [option] LVMID [interval] [count]各个参数详解&#xff1a; option&#xff1a;操作参数LVMID&#xff1a;本…

3.Spring-事务

一、隔离级别&#xff1a; 脏读&#xff1a; 一个事务访问到另外一个事务未提交的数据。 不可重复读&#xff1a; 事务内多次查询相同条件返回的结果不同。 幻读&#xff1a; 一个事务在前后两次查询同一个范围的时候&#xff0c;后一次查询看到了前一次查询没有看到的行。 二…