Unity照片墙简易圆形交互效果总结

还要很多可以优化的点地方,有兴趣的可以做
比如对象的销毁和生成可以做成对象池,走到最左边后再移动到最右边循环利用

分析过程文件,采用Blender,资源已上传,可以播放动画看效果,下面截个图:
在这里插入图片描述

视频效果如下:

anim

Untiy结构如下:
在这里插入图片描述
上面的ImageItem是我手动添加展示关系用的,默认就一个Target,PictureWall挂PictureWall脚本,ImageItem(预制体)挂ImageItemController 脚本即可

using UnityEngine;public class ImageItemController : MonoBehaviour
{public RectTransform target;public float speed = 10;[SerializeField]private float radiusScale = 1;public float horizontalOffset = 0;private RectTransform rect;private float radius = 0;private Vector2 originalPos = Vector2.zero;private bool isCheck = false;private bool isStartRotate = false;private Vector2 circleCenter;private float xDelta = 0;private float offset = 0;void Start(){rect = transform as RectTransform;rect.anchoredPosition = new Vector2(rect.anchoredPosition.x - horizontalOffset, rect.anchoredPosition.y);radius = target.rect.width * radiusScale;// * Random.Range(0.8f, 1); 半径可以在范围内随机}/* 1.现根据接触点计算出圆的路径:目标移动的位移,计算在圆的的位置,只需修改x即可,y保持不变* 2.计算出的位置x加上移动的距离,得出最总x的位置* 3.设置位置即可* 4.走远时的接触点:开始接触时的关于x对称位置  * 5.添加移动:平移原点和圆点即可*///移动void Update(){if (!isCheck){var dis = Vector2.Distance(target.anchoredPosition, rect.anchoredPosition);if (dis <= radius){isCheck = true;originalPos = rect.anchoredPosition;float y = Mathf.Abs(originalPos.y - target.anchoredPosition.y);float xToCircleCenter = Mathf.Sqrt(radius * radius - y * y);float x = originalPos.x - xToCircleCenter;circleCenter = new Vector2(x, target.anchoredPosition.y);isStartRotate = true;rect.SetSiblingIndex(transform.parent.childCount - 2);}}xDelta = Time.deltaTime * speed;rect.anchoredPosition = new Vector2(rect.anchoredPosition.x - xDelta, rect.anchoredPosition.y);if (isStartRotate){circleCenter.x -= xDelta;originalPos.x -= xDelta;float moveXDistance = target.anchoredPosition.x - circleCenter.x;float x = originalPos.x - circleCenter.x - moveXDistance;float y = Mathf.Sqrt(radius * radius - x * x);float maxY = radius;if (originalPos.y < circleCenter.y){y = -y;maxY = -radius;}Vector2 circlePoint = new Vector2(x, y);if (rect.anchoredPosition.x >= target.anchoredPosition.x){var v1 = circlePoint - (originalPos - circleCenter);var v2 = (originalPos - circleCenter) + new Vector2(0, maxY);v2.Normalize();offset = Vector2.Dot(v1, v2);}else{float tempX = originalPos.x - circleCenter.x;Vector2 originalPos2 = originalPos + 2 * new Vector2(-tempX, 0);var v1 = circlePoint - new Vector2(0, maxY);var v2 = originalPos2 - circleCenter + new Vector2(0, maxY);v2.Normalize();offset = -Vector2.Dot(v1, v2);}if (float.IsNaN(offset)){offset = 0;}x += moveXDistance + offset;Vector2 pos = circleCenter + new Vector2(x, y);rect.anchoredPosition = pos;if (target.anchoredPosition.x >= originalPos.x + originalPos.x - circleCenter.x){rect.anchoredPosition = originalPos;rect.SetAsFirstSibling();}else if (target.anchoredPosition.x <= circleCenter.x){rect.anchoredPosition = originalPos;rect.SetAsFirstSibling();}}if (rect.anchoredPosition.x < -rect.rect.width){Destroy(gameObject);}}
}
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
using Utility;public class PictureWall : MonoBehaviour
{[SerializeField]private GameObject prefab;private const float WIDTH = 3072;private const float HEIGHT = 1664;private int row = 6;private int column;private float intervalDistance = 20;[SerializeField]private float offset = 200;private float itemWidth;private float itemHeight;public float speed = 10;private float time = 0;[SerializeField]private RectTransform target;private string path = "/PictureWall/";private List<string> texturePaths;private int currentIndex = 0;private List<Texture2D> textureList;void Start(){textureList = new List<Texture2D>();path = Application.streamingAssetsPath + path;ReadImage();CalculateRowColumn();enabled = false;}private void ReadImage(){if (!Directory.Exists(path)){Directory.CreateDirectory(path);return;}texturePaths = new List<string>();var jpgs = Directory.GetFiles(path, "*.jpg");texturePaths.AddRange(jpgs);texturePaths.Reverse();if (texturePaths.Count > 100){for (int i = texturePaths.Count - 1; i == 100; i--){File.Delete(texturePaths[i]);texturePaths.RemoveAt(i);}}foreach (var filePath in texturePaths){UtilityLoadImage.I.LoadImage(filePath, tex =>{textureList.Add(tex);addNum++;if (addNum == texturePaths.Count){Spawn();}});}}float addNum = 0;private void Spawn(){float x = 0;float y = 0;for (int i = 0; i < row; i++){y = i * (itemHeight + intervalDistance);for (int j = 0; j < column; j++){x = j * (itemWidth + intervalDistance);if (i % 2 != 0){//x -= offset;}RectTransform rect = Instantiate(prefab, transform).transform as RectTransform;rect.pivot = new Vector2(0.5f, 0.5f);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemWidth);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, itemHeight);rect.anchoredPosition = new Vector2(x, -y) + new Vector2(rect.rect.width / 2, -rect.rect.height / 2);var controller = rect.GetComponent<ImageItemController>();controller.speed = speed;controller.target = target;if (i % 2 != 0){controller.horizontalOffset = offset;}SetTexture(rect);}}target.SetAsLastSibling();  enabled = true;}private void CalculateRowColumn(){itemHeight = (HEIGHT - (row - 1) * intervalDistance) / row;itemWidth = itemHeight * 16 / 9;//offset = itemWidth / 2;column = (int)(WIDTH / (itemWidth + intervalDistance)) + 3;time = itemWidth / speed;}bool isSpawned = false;private void Update(){if (!isSpawned && transform.childCount <= (column - 1) * row + 1){isSpawned = true;SpawnColumn();}}private void SpawnColumn(){float x = 0;float y = 0;for (int i = 0; i < row; i++){y = i * (itemHeight + intervalDistance);for (int j = 0; j < 1; j++){x = (column - 1) * (itemWidth + intervalDistance);RectTransform rect = Instantiate(prefab, transform).transform as RectTransform;rect.pivot = new Vector2(0.5f, 0.5f);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, itemWidth);rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, itemHeight);rect.anchoredPosition = new Vector2(x, -y) + new Vector2(intervalDistance - Time.deltaTime * speed, -rect.rect.height / 2);var controller = rect.GetComponent<ImageItemController>();controller.speed = speed;controller.target = target;if (i % 2 != 0){controller.horizontalOffset = offset;}SetTexture(rect);}}target.SetAsLastSibling();StartCoroutine(Delay());}private void SetTexture(RectTransform rect){        rect.GetComponent<RawImage>().texture = textureList[currentIndex];currentIndex = (currentIndex + 1) % texturePaths.Count;}private IEnumerator Delay(){//yield return new WaitForSeconds(0.1f);yield return null;isSpawned = false;}
}
工具类
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;namespace Utility
{public class UtilityLoadImage{public class MonoHelper : MonoBehaviour { }public static UtilityLoadImage I;private static MonoHelper helper;static UtilityLoadImage(){var go = new GameObject("UtilityLoadImage");helper = go.AddComponent<MonoHelper>();UnityEngine.Object.DontDestroyOnLoad(go);I = new UtilityLoadImage();}private UtilityLoadImage() { }#region  inner methodprivate IEnumerator LoadTexture2D(string path, Action<Texture2D> callback){           //Debug.Log("path:" + path);           UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(path);yield return uwr.SendWebRequest();if (uwr.downloadHandler.isDone){var tex = DownloadHandlerTexture.GetContent(uwr);callback?.Invoke(tex);}}private void LoadTexture2DByFile(string path, Action<Texture2D> callback){if (path.StartsWith("file://")){var bytes = File.ReadAllBytes(path);Texture2D tex = new Texture2D(1, 1);if (tex.LoadImage(bytes))callback?.Invoke(tex);}}private IEnumerator LoadByte(string path, Action<byte[]> callback){UnityWebRequest uwr = UnityWebRequest.Get(path);yield return uwr.SendWebRequest();if (uwr.downloadHandler.isDone){var data = uwr.downloadHandler.data;callback?.Invoke(data);}}private void DeleteFolder(string savedFolder, bool clearSavedPath, bool isRecursive = false){if (!Directory.Exists(savedFolder)){Debug.LogError("要删除的文件夹不存在!");return;}if (clearSavedPath){Directory.Delete(savedFolder, isRecursive);Directory.CreateDirectory(savedFolder);}}private byte[] Texture2DToByte(string path, Texture2D tex){byte[] data = null;int index = path.LastIndexOf('.');if (index != -1){string expandedName = path.Substring(index + 1);switch (expandedName){case "jpeg":case "jpg":data = tex.EncodeToJPG();break;case "png":data = tex.EncodeToPNG();break;default:Debug.Log("");break;}}else{Debug.Log("path is not correct!!!");}return data;}private IEnumerator LoadAudio(string path, string savedFolder, string fileName, Action<AudioClip> callback){UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);yield return request.SendWebRequest();if (request.downloadHandler.isDone){File.WriteAllBytes(savedFolder + "/" + fileName, request.downloadHandler.data);AudioClip clip = DownloadHandlerAudioClip.GetContent(request);callback?.Invoke(clip);}}private IEnumerator LoadAudio(string path, string savePath, Action<AudioClip> callback){UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);yield return request.SendWebRequest();if (request.downloadHandler.isDone){File.WriteAllBytes(savePath, request.downloadHandler.data);AudioClip clip = DownloadHandlerAudioClip.GetContent(request);callback?.Invoke(clip);}}private IEnumerator LoadAudio(string path, Action<AudioClip> callback){UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(path, AudioType.MPEG);yield return request.SendWebRequest();if (request.downloadHandler.isDone){AudioClip clip = DownloadHandlerAudioClip.GetContent(request);if (callback != null)callback(clip);elseDebug.Log("加载音频回调为null");}}#endregion#region load and download imagepublic void LoadImage(string path, Action<Texture2D> callback){helper.StartCoroutine(LoadTexture2D(path, callback));}public void LoadImageByFile(string path, Action<Texture2D> callback){LoadTexture2DByFile(path, callback);}public void LoadImages(string[] paths, Action<List<Texture2D>> callback){Debug.Log("start!!!!!");List<Texture2D> list = new List<Texture2D>();for (int i = 0; i < paths.Length; i++){LoadImage(paths[i], tex => list.Add(tex));}callback?.Invoke(list);Debug.Log("end!!!!!" + list.Count);}public void LoadImagesByFile(string[] paths, Action<List<Texture2D>> callback){List<Texture2D> list = new List<Texture2D>();for (int i = 0; i < paths.Length; i++){var data = File.ReadAllBytes(paths[i]);Texture2D tex = new Texture2D(1, 1);if (tex.LoadImage(data))list.Add(tex);}callback?.Invoke(list);}public void DownloadImageAndSave(string url, string savedFolder, string fileName, Action callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savedFolder + "/" + fileName, Texture2DToByte(url, tex));callback?.Invoke();}));}public void DownloadImageAndSave(string url, string savePath, Action callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savePath, Texture2DToByte(url, tex));callback?.Invoke();}));}public void DownloadImageAndSave_Texture2D(string url, string savedFolder, string fileName, Action<Texture2D> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savedFolder + "/" + fileName, Texture2DToByte(url, tex));callback?.Invoke(tex);}));}public void DownloadImageAndSave_Texture2D(string url, string savePath, Action<Texture2D> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savePath, Texture2DToByte(url, tex));callback?.Invoke(tex);}));}public void DownloadImageAndSave_FilePath(string url, string savedFolder, string fileName, Action<string> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{string path = savedFolder + "/" + fileName;File.WriteAllBytes(path, Texture2DToByte(url, tex));callback?.Invoke(path);}));}public void DownloadImageAndSave_FilePath(string url, string savePath, Action<string> callback = null){helper.StartCoroutine(LoadTexture2D(url, tex =>{File.WriteAllBytes(savePath, Texture2DToByte(url, tex));callback?.Invoke(savePath);}));}public void DownloadImagesAndSave(string[] urls, string savedFolder, string[] fileNames, Action completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;for (int i = 0; i < urls.Length; i++){DownloadImageAndSave(urls[i], savedFolder, fileNames[i], () =>{++completedNum;if (completedNum == urls.Length){completedCallback?.Invoke();Debug.Log("所以文件下载完成!");}});}}public void DownloadImagesAndSave_Texture2DPaths(string[] urls, string savedFolder, string[] fileNames, Action<string[]> callback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;string[] filePaths = new string[fileNames.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_FilePath(urls[i], savedFolder, fileNames[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == urls.Length){callback?.Invoke(filePaths);Debug.Log("所以图片下载完成!");}});}}public void DownloadImagesAndSave_Texture2DPaths(string[] urls, string[] savePaths, Action<string[]> callback = null){if (urls.Length != savePaths.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;string[] filePaths = new string[savePaths.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_FilePath(urls[i], savePaths[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == urls.Length){callback?.Invoke(filePaths);Debug.Log("所以图片下载完成!");}});}}public void DownloadImagesAndSave_Texture2Ds(string[] urls, string savedFolder, string[] fileNames, Action<Texture2D[]> callback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;Texture2D[] textures = new Texture2D[fileNames.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_Texture2D(urls[i], savedFolder, fileNames[i], tex =>{textures[completedNum] = tex;++completedNum;if (completedNum == urls.Length){callback?.Invoke(textures);Debug.Log("所以图片下载完成!");}});}}public void DownloadImagesAndSave_Texture2Ds(string[] urls, string[] savePaths, Action<Texture2D[]> callback = null){if (urls.Length != savePaths.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;Texture2D[] textures = new Texture2D[savePaths.Length];for (int i = 0; i < urls.Length; i++){DownloadImageAndSave_Texture2D(urls[i], savePaths[i], tex =>{textures[completedNum] = tex;++completedNum;if (completedNum == urls.Length){callback?.Invoke(textures);Debug.Log("所以图片下载完成!");}});}}#endregion#region download filepublic void DownloadFileAndSave(string url, string savedFolder, string fileName, Action callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savedFolder + "/" + fileName, data);callback?.Invoke();}));}public void DownloadFileAndSave(string url, string savePath, Action callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savePath, data);callback?.Invoke();}));}public void DownloadFileAndSave_FilePath(string url, string savedFolder, string fileName, Action<string> callback = null){helper.StartCoroutine(LoadByte(url, data =>{string path = savedFolder + "/" + fileName;File.WriteAllBytes(path, data);callback?.Invoke(path);}));}public void DownloadFileAndSave_FilePath(string url, string savePath, Action<string> callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savePath, data);callback?.Invoke(savePath);}));}public void DownloadFileAndSave_FileData(string url, string savedFolder, string fileName, Action<byte[]> callback = null){helper.StartCoroutine(LoadByte(url, data =>{string path = savedFolder + "/" + fileName;File.WriteAllBytes(path, data);callback?.Invoke(data);}));}public void DownloadFileAndSave_FileData(string url, string savePath, Action<byte[]> callback = null){helper.StartCoroutine(LoadByte(url, data =>{File.WriteAllBytes(savePath, data);callback?.Invoke(data);}));}public void DownloadFilesAndSave(string[] urls, string savedFolder, string[] fileNames, Action completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;for (int i = 0; i < urls.Length; i++){DownloadFileAndSave(urls[i], savedFolder, fileNames[i], () =>{++completedNum;if (completedNum == fileNames.Length){completedCallback?.Invoke();}});}}public void DownloadFilesAndSave(string[] urls, string[] savePath, Action callback = null){if (urls.Length != savePath.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;for (int i = 0; i < urls.Length; i++){DownloadFileAndSave(urls[i], savePath[i], () =>{++completedNum;if (completedNum == savePath.Length){callback?.Invoke();}});}}public void DownloadFilesAndSave_FilePaths(string[] urls, string savedFolder, string[] fileNames, Action<string[]> completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;string[] filePaths = new string[fileNames.Length];for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FilePath(urls[i], savedFolder, fileNames[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == fileNames.Length){completedCallback?.Invoke(filePaths);}});}}public void DownloadFilesAndSave_FilePaths(string[] urls, string[] savePath, Action<string[]> completedCallback = null){if (urls.Length != savePath.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;string[] filePaths = new string[savePath.Length];for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FilePath(urls[i], savePath[i], path =>{filePaths[completedNum] = path;++completedNum;if (completedNum == savePath.Length){completedCallback?.Invoke(filePaths);}});}}public void DownloadFilesAndSave_FileDatas(string[] urls, string savedFolder, string[] fileNames, Action<List<byte[]>> completedCallback = null, bool deleteFolder = false, bool recursive = false){if (urls.Length != fileNames.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}DeleteFolder(savedFolder, deleteFolder, recursive);int completedNum = 0;List<byte[]> allDatas = new List<byte[]>(fileNames.Length);for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FileData(urls[i], savedFolder, fileNames[i], data =>{allDatas.Add(data);++completedNum;if (completedNum == fileNames.Length){completedCallback?.Invoke(allDatas);}});}}public void DownloadFilesAndSave_FileDatas(string[] urls, string[] savePath, Action<List<byte[]>> completedCallback = null){if (urls.Length != savePath.Length){Debug.Log("下载数量和保存的文件数量不一致!");return;}int completedNum = 0;List<byte[]> allDatas = new List<byte[]>(savePath.Length);for (int i = 0; i < urls.Length; i++){DownloadFileAndSave_FileData(urls[i], savePath[i], data =>{allDatas.Add(data);++completedNum;if (completedNum == savePath.Length){completedCallback?.Invoke(allDatas);}});}}#endregion#region download audiopublic void DownloadAudioAndSave_FileData(string url, string savedFolder, string fileName, Action<AudioClip> callback = null){helper.StartCoroutine(LoadAudio(url, savedFolder, fileName, callback));}public void DownloadAudioAndSave_FileData(string url, string savePath, Action<AudioClip> callback = null){helper.StartCoroutine(LoadAudio(url, savePath, callback));}public void LoadAudioClip(string url, Action<AudioClip> callback = null){helper.StartCoroutine(LoadAudio(url, callback));}#endregion}
}

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

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

相关文章

关系型数据库mysql(8)sql高级语句②

目录 一.子查询——Subquery 语法 环境准备 In——查询已知的值的数据记录 子查询——Insert 子查询——Update 子查询——Delete Not In——表示否定&#xff0c;不在子查询的结果集里 Exists——判断查询结果集是否为空 子查询——别名 ​编辑 二.视图 理论&a…

图论之路径条数专题

一直忙着金工实习蓝桥杯&#xff0c;好久没有看图论了&#xff0c;今天就小试几题享受下被虐的快感。 1.最短路拓扑 首先来几个结论&#xff1a; 1.最短路图没有环&#xff08;可以用反证法证明&#xff09; 2.dis[u]edge[u,v]dis[v]&#xff0c;那么u,v端点的边一定在最短路…

selenium自动化测试

selenium自动化测试 1、Javaselenium环境搭建2、测试&#xff0c;打开任意网页3、selenium 常见的Api3.1元素定位findElement3.1.1 css 选择语法3.1.2 xpath 选择语法 1、Javaselenium环境搭建 下载chromedriver&#xff0c;版本要与Chrome浏览器版本一致。 下载之后将chro…

第P1周:实现mnist手写数字识别

>- **&#x1f368; 本文为[&#x1f517;365天深度学习训练营](https://mp.weixin.qq.com/s/0dvHCaOoFnW8SCp3JpzKxg) 中的学习记录博客** >- **&#x1f356; 原作者&#xff1a;[K同学啊 | 接辅导、项目定制](https://mtyjkh.blog.csdn.net/)** 目录 一、前言 二、我…

vant checkbox 复选框 样式改写

修改前 修改后 基于 vant&#xff1a; 4.8.3 unocss: 0.53.4 <van-checkbox-group v-model"query.zczb" shape"square" class"text-16 w-100% flex flex-wrap"><template v-for"item in registerCapitalOption"><v…

LeetCode 27 移除元素

给你一个数组 nums 和一个值 val&#xff0c;你需要 原地 移除所有数值等于 val 的元素&#xff0c;并返回移除后数组的新长度。 不要使用额外的数组空间&#xff0c;你必须仅使用 O(1) 额外空间并 原地 修改输入数组。 元素的顺序可以改变。你不需要考虑数组中超出新长度后面…

“预防儿童烧烫伤”科普安全课堂走进嘉鱼县第一小学

为提高嘉鱼县儿童烧烫伤安全意识、隐患识别能力以及突发应急处置能力&#xff0c;3月26日下午&#xff0c;在中国社会福利基金会烧烫伤关爱公益基金、嘉鱼县妇女联合会、嘉鱼县教育局的支持下&#xff0c;嘉鱼县蒲公英社会工作服务中心走进嘉鱼县第一小学开展预防儿童烧烫伤科普…

基于Spring Boot 3 + Spring Security6 + JWT + Redis实现登录、token身份认证

基于Spring Boot3实现Spring Security6 JWT Redis实现登录、token身份认证。 用户从数据库中获取。使用RESTFul风格的APi进行登录。使用JWT生成token。使用Redis进行登录过期判断。所有的工具类和数据结构在源码中都有。 系列文章指路&#x1f449; 系列文章-基于Vue3创建前端…

MongoDB内存过高问题分析解决

告警 公司有个3.2.7版本的mongo复制集&#xff0c;最近几天频繁告警内存过高。 服务器配置16C64G内存。mongo备节点内存使用到55G&#xff0c;触发告警。 以下内容基于3.2.7版本&#xff0c;3.2.7版本已经太老&#xff0c;很多后来的命令和配置&#xff0c;3.2.7都没有。 …

【黑马头条】-day04自媒体文章审核-阿里云接口-敏感词分析DFA-图像识别OCR-异步调用MQ

文章目录 day4学习内容自媒体文章自动审核今日内容 1 自媒体文章自动审核1.1 审核流程1.2 内容安全第三方接口1.3 引入阿里云内容安全接口1.3.1 添加依赖1.3.2 导入aliyun模块1.3.3 注入Bean测试 2 app端文章保存接口2.1 表结构说明2.2 分布式id2.2.1 分布式id-技术选型2.2.2 雪…

Unity2018发布安卓报错 Exception: Gradle install not valid

Unity2018发布安卓报错 Exception: Gradle install not valid Exception: Gradle install not valid UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action1[T] progress) (at <c67d1645d7ce4b76823a39080b82c1d1>:0) …

Prometheus +Grafana +node_exporter可视化监控Linux虚机

1、介绍 待补充 2、架构图 待补充 Prometheus &#xff1a;主要是负责存储、抓取、聚合、查询方面。 node_exporter &#xff1a;主要是负责采集物理机、中间件的信息。 3、搭建过程 配置要求&#xff1a;1台主服务器 n台从服务器 &#xff08;被监控的linux虚机&am…

MoneyPrinterTurbo搭建详细流程(Linux)及常见问题

先附上链接: MoneyPrinterTurbohttps://github.com/harry0703/MoneyPrinterTurboMoneyPrinterTurbo是一款合成视频的软件。 你只需要提供一个主题或者关键字,就可以全自动生成视频文案、视频素材、视频字幕、视频背景音乐,然后合成一个高清的短视频。 接下来讲解详细的搭…

macOS 13 Ventura (苹果最新系统) v13.6.6正式版

macOS 13 Ventura是苹果电脑的全新操作系统&#xff0c;它为用户带来了众多引人注目的新功能和改进。该系统加强了FaceTime和视频通话的体验&#xff0c;同时优化了邮件、Safari浏览器和日历等内置应用程序&#xff0c;使其更加流畅、快速和安全。特别值得一提的是&#xff0c;…

测试人进阶技能:单元测试报告应用指南

为什么需要单元测试 从产品角度而言&#xff0c;常规的功能测试、系统测试都是站在产品局部或全局功能进行测试&#xff0c;能够很好地与用户的需要相结合&#xff0c;但是缺乏了对产品研发细节&#xff08;特别是代码细节的理解&#xff09;。 从测试人员角度而言&#xff0…

MySQL索引18连问,谁能顶住

前言 过完这个节&#xff0c;就要进入金银季&#xff0c;准备了 18 道 MySQL 索引题&#xff0c;一定用得上。 作者&#xff1a;感谢每一个支持&#xff1a; github 1. 索引是什么 索引是一种数据结构&#xff0c;用来帮助提升查询和检索数据速度。可以理解为一本书的目录&…

Hadoop面试重点

文章目录 1. Hadoop 常用端口号2.Hadoop特点3.Hadoop1.x、2.x、3.x区别 1. Hadoop 常用端口号 hadoop2.xhadoop3.x访问HDFS 端口500709870访问 MR 执行情况端口80888088历史服务器1988819888客户端访问集群端口90008020 2.Hadoop特点 高可靠&#xff1a;Hadoop底层维护多个数…

Spring boot 发送文本邮件 和 html模板邮件

Spring boot 发送文本邮件 和 html模板邮件 提示&#xff1a;这里使用 spring-boot-starter-mail 发送文本邮件 和 html模板邮件 文章目录 Spring boot 发送文本邮件 和 html模板邮件一、开启QQ邮箱里的POP3/SMTP服务①&#xff1a;开启步骤 二、简单配置①&#xff1a;引入依赖…

8.均值滤波

1 简介 均值滤波是一种低通滤波&#xff0c;它可以有效过滤图片中的椒盐噪声&#xff0c;但是副作用也同样明显&#xff0c;会使图片的边缘过于模糊。   均值滤波的卷积核系数均为1。   这里最终重复一下算法实现以及验证的步骤&#xff1a;     1.MATLAB读取图片并转化…

macOS Sonoma如何查看隐藏文件

在使用Git进行项目版本控制时&#xff0c;我们可能会遇到一些隐藏文件&#xff0c;比如.gitkeep文件。它通常出现在Git项目的子目录中&#xff0c;主要作用是确保空目录也可以被跟踪。 终端命令 在尝试查看.gitkeep文件时&#xff0c;使用Terminal命令来显示隐藏文件 default…