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

【unity进阶知识9】序列化字典,场景,vector,color,Quaternion

文章目录

  • 前言
  • 一、可序列化字典类
    • 普通字典简单的使用
    • 可序列化字典简单的使用
  • 二、序列化场景
  • 三、序列化vector
  • 四、序列化color
  • 五、序列化旋转Quaternion
  • 完结

前言

自定义序列化的主要原因:

  1. 可读性:使数据结构更清晰,便于理解和维护。
  2. 优化 Inspector:提供更友好的用户界面,方便编辑和查看数据。
  3. 控制序列化:实现特定的序列化逻辑,灵活处理数据。比如在保存或加载时进行特定的转换或处理。
  4. 性能提升:减少内存占用,提高序列化和反序列化的效率。
  5. 易于扩展:根据项目需求灵活添加字段和功能。
  6. 类型安全:确保使用正确的数据类型,减少错误。

一、可序列化字典类

Unity 无法序列化标准词典。这意味着它们不会在检查器中显示或编辑,
也不会在启动时实例化。一个经典的解决方法是将键和值存储在单独的数组中,并在启动时构造字典。

我们使用gitthub大佬的源码即可,此项目提供了一个通用字典类及其自定义属性抽屉来解决此问题。
源码地址:https://github.com/azixMcAze/Unity-SerializableDictionary

你可以选择下载源码,也可以直接复制我下面的代码,我把主要代码提出来了
SerializableDictionary.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using UnityEngine;public abstract class SerializableDictionaryBase
{public abstract class Storage {}protected class Dictionary<TKey, TValue> : System.Collections.Generic.Dictionary<TKey, TValue>{public Dictionary() {}public Dictionary(IDictionary<TKey, TValue> dict) : base(dict) {}public Dictionary(SerializationInfo info, StreamingContext context) : base(info, context) {}}
}[Serializable]
public abstract class SerializableDictionaryBase<TKey, TValue, TValueStorage> : SerializableDictionaryBase, IDictionary<TKey, TValue>, IDictionary, ISerializationCallbackReceiver, IDeserializationCallback, ISerializable
{Dictionary<TKey, TValue> m_dict;[SerializeField]TKey[] m_keys;[SerializeField]TValueStorage[] m_values;public SerializableDictionaryBase(){m_dict = new Dictionary<TKey, TValue>();}public SerializableDictionaryBase(IDictionary<TKey, TValue> dict){	m_dict = new Dictionary<TKey, TValue>(dict);}protected abstract void SetValue(TValueStorage[] storage, int i, TValue value);protected abstract TValue GetValue(TValueStorage[] storage, int i);public void CopyFrom(IDictionary<TKey, TValue> dict){m_dict.Clear();foreach (var kvp in dict){m_dict[kvp.Key] = kvp.Value;}}public void OnAfterDeserialize(){if(m_keys != null && m_values != null && m_keys.Length == m_values.Length){m_dict.Clear();int n = m_keys.Length;for(int i = 0; i < n; ++i){m_dict[m_keys[i]] = GetValue(m_values, i);}m_keys = null;m_values = null;}}public void OnBeforeSerialize(){int n = m_dict.Count;m_keys = new TKey[n];m_values = new TValueStorage[n];int i = 0;foreach(var kvp in m_dict){m_keys[i] = kvp.Key;SetValue(m_values, i, kvp.Value);++i;}}#region IDictionary<TKey, TValue>public ICollection<TKey> Keys {	get { return ((IDictionary<TKey, TValue>)m_dict).Keys; } }public ICollection<TValue> Values { get { return ((IDictionary<TKey, TValue>)m_dict).Values; } }public int Count { get { return ((IDictionary<TKey, TValue>)m_dict).Count; } }public bool IsReadOnly { get { return ((IDictionary<TKey, TValue>)m_dict).IsReadOnly; } }public TValue this[TKey key]{get { return ((IDictionary<TKey, TValue>)m_dict)[key]; }set { ((IDictionary<TKey, TValue>)m_dict)[key] = value; }}public void Add(TKey key, TValue value){((IDictionary<TKey, TValue>)m_dict).Add(key, value);}public bool ContainsKey(TKey key){return ((IDictionary<TKey, TValue>)m_dict).ContainsKey(key);}public bool Remove(TKey key){return ((IDictionary<TKey, TValue>)m_dict).Remove(key);}public bool TryGetValue(TKey key, out TValue value){return ((IDictionary<TKey, TValue>)m_dict).TryGetValue(key, out value);}public void Add(KeyValuePair<TKey, TValue> item){((IDictionary<TKey, TValue>)m_dict).Add(item);}public void Clear(){((IDictionary<TKey, TValue>)m_dict).Clear();}public bool Contains(KeyValuePair<TKey, TValue> item){return ((IDictionary<TKey, TValue>)m_dict).Contains(item);}public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex){((IDictionary<TKey, TValue>)m_dict).CopyTo(array, arrayIndex);}public bool Remove(KeyValuePair<TKey, TValue> item){return ((IDictionary<TKey, TValue>)m_dict).Remove(item);}public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator(){return ((IDictionary<TKey, TValue>)m_dict).GetEnumerator();}IEnumerator IEnumerable.GetEnumerator(){return ((IDictionary<TKey, TValue>)m_dict).GetEnumerator();}#endregion#region IDictionarypublic bool IsFixedSize { get { return ((IDictionary)m_dict).IsFixedSize; } }ICollection IDictionary.Keys { get { return ((IDictionary)m_dict).Keys; } }ICollection IDictionary.Values { get { return ((IDictionary)m_dict).Values; } }public bool IsSynchronized { get { return ((IDictionary)m_dict).IsSynchronized; } }public object SyncRoot { get { return ((IDictionary)m_dict).SyncRoot; } }public object this[object key]{get { return ((IDictionary)m_dict)[key]; }set { ((IDictionary)m_dict)[key] = value; }}public void Add(object key, object value){((IDictionary)m_dict).Add(key, value);}public bool Contains(object key){return ((IDictionary)m_dict).Contains(key);}IDictionaryEnumerator IDictionary.GetEnumerator(){return ((IDictionary)m_dict).GetEnumerator();}public void Remove(object key){((IDictionary)m_dict).Remove(key);}public void CopyTo(Array array, int index){((IDictionary)m_dict).CopyTo(array, index);}#endregion#region IDeserializationCallbackpublic void OnDeserialization(object sender){((IDeserializationCallback)m_dict).OnDeserialization(sender);}#endregion#region ISerializableprotected SerializableDictionaryBase(SerializationInfo info, StreamingContext context) {m_dict = new Dictionary<TKey, TValue>(info, context);}public void GetObjectData(SerializationInfo info, StreamingContext context){((ISerializable)m_dict).GetObjectData(info, context);}#endregion
}public static class SerializableDictionary
{public class Storage<T> : SerializableDictionaryBase.Storage{public T data;}
}[Serializable]
public class SerializableDictionary<TKey, TValue> : SerializableDictionaryBase<TKey, TValue, TValue>
{public SerializableDictionary() {}public SerializableDictionary(IDictionary<TKey, TValue> dict) : base(dict) {}protected SerializableDictionary(SerializationInfo info, StreamingContext context) : base(info, context) {}protected override TValue GetValue(TValue[] storage, int i){return storage[i];}protected override void SetValue(TValue[] storage, int i, TValue value){storage[i] = value;}
}[Serializable]
public class SerializableDictionary<TKey, TValue, TValueStorage> : SerializableDictionaryBase<TKey, TValue, TValueStorage> where TValueStorage : SerializableDictionary.Storage<TValue>, new()
{public SerializableDictionary() {}public SerializableDictionary(IDictionary<TKey, TValue> dict) : base(dict) {}protected SerializableDictionary(SerializationInfo info, StreamingContext context) : base(info, context) {}protected override TValue GetValue(TValueStorage[] storage, int i){return storage[i].data;}protected override void SetValue(TValueStorage[] storage, int i, TValue value){storage[i] = new TValueStorage();storage[i].data = value;}
}

普通字典简单的使用

public class SerializedTest : MonoBehaviour {//普通字典public Dictionary<string, string> dictionary;private void Start() {//实例化字典dictionary = new Dictionary<string, string>();//添加键值对dictionary.Add("name1", "小明");dictionary["name2"] = "小红";//检查是否包含指定的键string key = "name1";Debug.Log($"是否包含键为{key}{dictionary.ContainsKey(key)}");//检查是否包含指定的值string value = "小红";Debug.Log($"是否包含值为{value}{dictionary.ContainsValue(value)}");//获取指定键的值Debug.Log($"获取键为name2的值:{dictionary["name2"]}");//移除键值对dictionary.Remove("name1");//获取键值对数量Debug.Log($"获取键值对数量:{dictionary.Count}");//清空字典dictionary.Clear();}
}

结果
在这里插入图片描述

可序列化字典简单的使用

和普通字典的使用方法一样,只需要把Dictionary换成SerializableDictionary,并且使用时不需要先实例化了

public class SerializedTest : MonoBehaviour {//可序列化字典public SerializableDictionary<string, string> serializableDictionary;private void Start() {//添加键值对serializableDictionary.Add("name1", "小明");serializableDictionary["name2"] = "小红";//检查是否包含指定的键string key = "name1";Debug.Log($"是否包含键为{key}{serializableDictionary.ContainsKey(key)}");//获取指定键的值Debug.Log($"获取键为name2的值:{serializableDictionary["name2"]}");//移除键值对serializableDictionary.Remove("name1");//获取键值对数量Debug.Log($"获取键值对数量:{serializableDictionary.Count}");//清空字典//serializableDictionary.Clear();}
}

结果
在这里插入图片描述
运行时,在挂载的脚本上也可以直接显示字典的值
在这里插入图片描述

二、序列化场景

正常我们都是按场景名称或者索引去跟踪我们的场景吗,这里其实有一个更好的方法,之后在所有的项目中我们都可以去使用它

灵感来源于一篇Unity论坛的SceneField代码:
https://discussions.unity.com/t/inspector-field-for-scene-asset/40763
在这里插入图片描述
解释:这是代码通过使用SceneField类和SceneFieldPropertyDrawer属性绘制器,开发者可以在自定义的脚本中方便地引用和管理场景对象,并在Inspector面板中进行编辑和选择操作。这对于需要频繁切换场景或者处理多个场景的情况非常有用。

新增SerializableScene.cs脚本,如下

using UnityEngine;#if UNITY_EDITOR
using UnityEditor;
#endif[System.Serializable]
public class SerializableScene
{[SerializeField]private Object m_SceneAsset;[SerializeField]private string m_SceneName = "";public string SceneName{get { return m_SceneName; }}// 使其与现有的Unity方法(LoadLevel / LoadScene)兼容public static implicit operator string(SerializableScene sceneField){return sceneField.SceneName;}
}#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(SerializableScene))]
public class SceneFieldPropertyDrawer : PropertyDrawer
{public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label){EditorGUI.BeginProperty(_position, GUIContent.none, _property);SerializedProperty sceneAsset = _property.FindPropertyRelative("m_SceneAsset");SerializedProperty sceneName = _property.FindPropertyRelative("m_SceneName");_position = EditorGUI.PrefixLabel(_position, GUIUtility.GetControlID(FocusType.Passive), _label);if (sceneAsset != null){// 显示场景选择器,让用户选择一个场景sceneAsset.objectReferenceValue = EditorGUI.ObjectField(_position, sceneAsset.objectReferenceValue, typeof(SceneAsset), false);// 如果已经选择了场景,则将场景名称保存在场景名称变量中if (sceneAsset.objectReferenceValue != null){sceneName.stringValue = (sceneAsset.objectReferenceValue as SceneAsset).name;}}EditorGUI.EndProperty();}
}
#endif

测试调用

public class SerializedTest : MonoBehaviour {//可序列化场景public SerializableScene scene1;public SerializableScene scene2;private void Start() {SceneManager.LoadScene(scene1);//跳转场景}
}

绑定数据
在这里插入图片描述

三、序列化vector

新增SerializedVector.cs代码

using System;
using UnityEngine;/// <summary>
/// 定义一个可序列化的Vector3结构
/// </summary>
[Serializable]
public struct SerializedVector3 : IEquatable<SerializedVector3>
{public float x, y, z; // 向量的x、y、z分量// 构造函数,用于初始化向量public SerializedVector3(float x, float y, float z){this.x = x;this.y = y;this.z = z;}// 判断当前向量是否与其他向量相等public bool Equals(SerializedVector3 other){return this.x == other.x && this.y == other.y && this.z == other.z;}// 重写ToString方法,返回向量的字符串表示public override string ToString(){return $"({x},{y},{z})";}// 重写GetHashCode方法,生成哈希值public override int GetHashCode(){return x.GetHashCode() ^ (y.GetHashCode() << 2) ^ (z.GetHashCode() >> 2);}// 隐式转换:SerializedVector3 -> Vector3public static implicit operator SerializedVector3(Vector3 vector3){return new SerializedVector3(vector3.x, vector3.y, vector3.z);}// 隐式转换:Vector3 -> SerializedVector3public static implicit operator Vector3(SerializedVector3 vector3){return new Vector3(vector3.x, vector3.y, vector3.z);}// 隐式转换:SerializedVector3 -> Vector3Intpublic static implicit operator SerializedVector3(Vector3Int vector3){return new SerializedVector3(vector3.x, vector3.y, vector3.z);}// 隐式转换:Vector3Int -> SerializedVector3public static implicit operator Vector3Int(SerializedVector3 vector3){return new Vector3Int((int)vector3.x, (int)vector3.y, (int)vector3.z);}
}/// <summary>
/// 定义一个可序列化的Vector2结构
/// </summary>
[Serializable]
public struct SerializedVector2 : IEquatable<SerializedVector2>
{public float x, y; // 向量的x、y分量// 构造函数,用于初始化向量public SerializedVector2(float x, float y){this.x = x;this.y = y;}// 判断当前向量是否与其他向量相等public bool Equals(SerializedVector2 other){return this.x == other.x && this.y == other.y;}// 重写ToString方法,返回向量的字符串表示public override string ToString(){return $"({x},{y})";}// 重写GetHashCode方法,生成哈希值public override int GetHashCode(){return x.GetHashCode() ^ (y.GetHashCode() << 2);}// 隐式转换:SerializedVector2 -> Vector2public static implicit operator SerializedVector2(Vector2 vector2){return new SerializedVector2(vector2.x, vector2.y);}// 隐式转换:Vector2 -> SerializedVector2public static implicit operator Vector2(SerializedVector2 vector2){return new Vector2(vector2.x, vector2.y);}// 隐式转换:SerializedVector2 -> Vector2Intpublic static implicit operator SerializedVector2(Vector2Int vector2){return new SerializedVector2(vector2.x, vector2.y);}// 隐式转换:Vector2Int -> SerializedVector2public static implicit operator Vector2Int(SerializedVector2 vector2){return new Vector2Int((int)vector2.x, (int)vector2.y);}
}// 扩展方法类,用于转换向量
public static class SerializedVectorExtensions
{// 将SerializedVector3转换为Vector3public static Vector3 ConverToVector3(this SerializedVector3 sv3){return new Vector3(sv3.x, sv3.y, sv3.z);}// 将Vector3转换为SerializedVector3public static SerializedVector3 ConverToSVector3(this Vector3 v3){return new SerializedVector3(v3.x, v3.y, v3.z);}// 将SerializedVector3转换为Vector3Intpublic static Vector3Int ConverToVector3Int(this SerializedVector3 sv3){return new Vector3Int((int)sv3.x, (int)sv3.y, (int)sv3.z);}// 将Vector3Int转换为SerializedVector3public static SerializedVector3 ConverToSVector3Int(this Vector3Int v3){return new SerializedVector3(v3.x, v3.y, v3.z);}// 将SerializedVector2转换为Vector2public static Vector2 ConverToSVector2(this SerializedVector2 sv2){return new Vector2(sv2.x, sv2.y);}// 将SerializedVector2转换为Vector2Intpublic static Vector2Int ConverToVector2Int(this SerializedVector2 sv2){return new Vector2Int((int)sv2.x, (int)sv2.y);}// 将Vector2转换为SerializedVector2public static SerializedVector2 ConverToSVector2(this Vector2 v2){return new SerializedVector2(v2.x, v2.y);}// 将Vector2Int转换为SerializedVector2public static SerializedVector2 ConverToSVector2(this Vector2Int v2){return new SerializedVector2(v2.x, v2.y);}
}

测试调用

//普通Vector
public Vector3 vector3;
public Vector2 vector2;
//可序列化Vector
public SerializedVector3 serializedVector3;
public SerializedVector2 serializedVector2;//Vector3和SerializedVector3可以随意转换
Debug.Log(vector3);
vector3 = serializedVector3;
Debug.Log(vector3);
serializedVector3 = Vector3.zero;
Debug.Log(serializedVector3);

配置
在这里插入图片描述
结果
在这里插入图片描述

四、序列化color

新增SerializableColor.cs

using UnityEngine;
using System;/// <summary>
/// 可序列化的颜色结构
/// </summary>
[Serializable]
public struct SerializedColor
{public float r, g, b, a; // 颜色的红、绿、蓝和透明度分量// 构造函数,用于初始化颜色public SerializedColor(float r, float g, float b, float a){this.r = r; // 红色分量this.g = g; // 绿色分量this.b = b; // 蓝色分量this.a = a; // 透明度分量}// 重写ToString方法,返回颜色的字符串表示public override string ToString(){return $"({r},{g},{b},{a})"; // 格式化输出颜色分量}// 重写GetHashCode方法,返回颜色的哈希值public override int GetHashCode(){return this.ConverToUnityColor().GetHashCode(); // 使用Unity的颜色哈希值}// 隐式转换:Color -> SerializedColorpublic static implicit operator SerializedColor(Color color){return new SerializedColor(color.r, color.g, color.b, color.a); // 从Unity的Color转换为SerializedColor}// 隐式转换:SerializedColor -> Colorpublic static implicit operator Color(SerializedColor color){return new Color(color.r, color.g, color.b, color.a); // 从SerializedColor转换为Unity的Color}
}/// <summary>
/// 颜色序列化扩展方法类
/// </summary>
public static class Serialization_ColorExtensions
{// 将SerializedColor转换为Unity的Colorpublic static Color ConverToUnityColor(this SerializedColor color){return new Color(color.r, color.g, color.b, color.a); // 创建并返回Unity的Color}// 将Unity的Color转换为SerializedColorpublic static SerializedColor ConverToSerializationColor(this Color color){return new SerializedColor(color.r, color.g, color.b, color.a); // 创建并返回SerializedColor}
}

测试调用

//颜色
public Color color;
//可序列化的颜色
public SerializedColor serializedColor;color = new Color(1.0f, 0.5f, 0.0f, 1.0f);
Debug.Log(color);
serializedColor = new SerializedColor(0.0f, 1.0f, 0.0f, 1.0f);
Debug.Log(serializedColor);
color = serializedColor;
Debug.Log(color);

配置
在这里插入图片描述

在这里插入图片描述

五、序列化旋转Quaternion

新增SerializedQuaternion.cs,这个其实和vector序列号类似

using System;
using UnityEngine;/// <summary>
/// 定义一个可序列化的Quaternion结构
/// </summary>
[Serializable]
public struct SerializedQuaternion : IEquatable<SerializedQuaternion>
{public float x, y, z, w; // 四元数的x、y、z、w分量// 构造函数,用于初始化四元数public SerializedQuaternion(float x, float y, float z, float w){this.x = x;this.y = y;this.z = z;this.w = w;}// 判断当前四元数是否与其他四元数相等public bool Equals(SerializedQuaternion other){return this.x == other.x && this.y == other.y && this.z == other.z && this.w == other.w;}// 重写ToString方法,返回四元数的字符串表示public override string ToString(){return $"({x}, {y}, {z}, {w})";}// 重写GetHashCode方法,生成四元数的哈希值public override int GetHashCode(){return x.GetHashCode() ^ (y.GetHashCode() << 2) ^ (z.GetHashCode() >> 2) ^ (w.GetHashCode() << 1);}// 隐式转换:从Unity的Quaternion类型转换为SerializedQuaternionpublic static implicit operator SerializedQuaternion(Quaternion quaternion){return new SerializedQuaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w);}// 隐式转换:从SerializedQuaternion转换为Unity的Quaternion类型public static implicit operator Quaternion(SerializedQuaternion quaternion){return new Quaternion(quaternion.x, quaternion.y, quaternion.z, quaternion.w);}
}// 扩展方法类,用于转换四元数
public static class SerializedQuaternionExtensions
{// 将SerializedQuaternion转换为Unity的Quaternion类型public static Quaternion ConvertToQuaternion(this SerializedQuaternion sq){return new Quaternion(sq.x, sq.y, sq.z, sq.w);}// 将Unity的Quaternion类型转换为SerializedQuaternionpublic static SerializedQuaternion ConvertToSQuaternion(this Quaternion q){return new SerializedQuaternion(q.x, q.y, q.z, q.w);}
}

测试调用

//旋转
public Quaternion quaternion;
//可序列化旋转
public SerializedQuaternion serializedQuaternion;// 定义一个欧拉角(绕X、Y、Z轴的旋转)    
Vector3 eulerAngles = new Vector3(30f, 45f, 60f); 
// 将欧拉角转换为四元数
quaternion = Quaternion.Euler(eulerAngles);
// 将四元数转换为欧拉角
eulerAngles = quaternion.eulerAngles;
Debug.Log(eulerAngles);//直接赋值
serializedQuaternion = Quaternion.Euler(eulerAngles);
serializedQuaternion = quaternion;//互相转换
serializedQuaternion = quaternion.ConvertToSQuaternion();
quaternion = serializedQuaternion.ConvertToQuaternion();

完结

赠人玫瑰,手有余香!如果文章内容对你有所帮助,请不要吝啬你的点赞评论和关注,你的每一次支持都是我不断创作的最大动力。当然如果你发现了文章中存在错误或者有更好的解决方法,也欢迎评论私信告诉我哦!

好了,我是向宇,https://xiangyu.blog.csdn.net

一位在小公司默默奋斗的开发者,闲暇之余,边学习边记录分享,站在巨人的肩膀上,通过学习前辈们的经验总是会给我很多帮助和启发!如果你遇到任何问题,也欢迎你评论私信或者加群找我, 虽然有些问题我也不一定会,但是我会查阅各方资料,争取给出最好的建议,希望可以帮助更多想学编程的人,共勉~
在这里插入图片描述

相关文章:

【unity进阶知识9】序列化字典,场景,vector,color,Quaternion

文章目录 前言一、可序列化字典类普通字典简单的使用可序列化字典简单的使用 二、序列化场景三、序列化vector四、序列化color五、序列化旋转Quaternion完结 前言 自定义序列化的主要原因&#xff1a; 可读性&#xff1a;使数据结构更清晰&#xff0c;便于理解和维护。优化 I…...

传奇GOM引擎架设好进游戏后提示请关闭非法外挂,重新登录,如何处理?

今天在架设一个GOM引擎的版本时&#xff0c;进游戏之后刚开始是弹出一个对话框&#xff0c;提示请关闭非法外挂&#xff0c;重新登录&#xff0c;我用的是绿盟登陆器&#xff0c;同时用的也是绿盟插件&#xff0c;刚开始我以为是绿盟登录器的问题&#xff0c;于是就换成原版gom…...

OpenCV视频I/O(15)视频写入类VideoWriter之标识视频编解码器函数fourcc()的使用

操作系统&#xff1a;ubuntu22.04 OpenCV版本&#xff1a;OpenCV4.9 IDE:Visual Studio Code 编程语言&#xff1a;C11 算法描述 将 4 个字符拼接成一个 FourCC 代码。 在 OpenCV 中&#xff0c;fourcc() 函数用于生成 FourCC 代码&#xff0c;这是一种用于标识视频编解码器的…...

rust log选型

考察了最火的tracing。但是该模块不支持compact&#xff0c;仅支持根据时间进行rotate。 daily Creates a daily-rotating file appender. hourly Creates an hourly-rotating file appender. minutely Creates a minutely-rotating file appender. This will rotate the log…...

数据库-分库分表

什么是分库分表 分库分表是一种数据库优化策略。 目的&#xff1a;为了解决由于单一的库表数据量过大而导致数据库性能降低的问题 分库&#xff1a;将原来独立的数据库拆分成若干数据库组成 分表&#xff1a;将原来的大表(存储近千万数据的表)拆分成若干个小表 什么时候考虑分…...

基于SSM的校园社团管理系统的设计 社团信息管理 智慧社团管理社团预约系统 社团活动管理 社团人员管理 在线社团管理社团资源管理(源码+定制+文档)

博主介绍&#xff1a; ✌我是阿龙&#xff0c;一名专注于Java技术领域的程序员&#xff0c;全网拥有10W粉丝。作为CSDN特邀作者、博客专家、新星计划导师&#xff0c;我在计算机毕业设计开发方面积累了丰富的经验。同时&#xff0c;我也是掘金、华为云、阿里云、InfoQ等平台…...

【SVN】一文读懂Subversion(SVN)

SVN 一、SVN简介1. 概念1.1 repository&#xff08;源代码库&#xff09;1.2 Checkout&#xff08;提取&#xff09;1.3 Commit&#xff08;提交&#xff09;1.4 Update (更新) 2. SVN的主要功能2.1 目录版本控制2.2 真实的版本历史2.3 自动提交2.4 纳入版本控管的元数据2.5 选…...

nginx打包部署前端vue项目全过程【保姆级教程】

&#x1f939;‍♀️潜意识起点&#xff1a;个人主页 &#x1f399;座右铭&#xff1a;得之坦然&#xff0c;失之淡然。 &#x1f48e;擅长领域&#xff1a;前端 是的&#xff0c;我需要您的&#xff1a; &#x1f9e1;点赞❤️关注&#x1f499;收藏&#x1f49b; 是我持…...

From SAM to CAMs

feature map F 不建议复现...

【NLP自然语言处理】01-基础学习路径简介

目的&#xff1a;让大家能够在 AI-NLP 领域由基础到入门具体安排&#xff1a; NLP介绍 文本预处理RNN 及其变体&#xff08;涉及案例&#xff09;Transformer 原理详解迁移学习 和 Bert 模型详解 &#xff08;涉及案例&#xff09;特点&#xff1a; 原理 实践每个文章会有练习…...

ffmpeg取rtsp流音频数据保存声音为wav文件

本来不是什么难搞的问题&#xff0c;代码写完了&#xff0c;音频流信息中的详细信息&#xff0c;具体代码表现为 format_ctx->streams[audio_stream_index]->codecpar是空指针。 这个查了一圈也没人给出正确答案&#xff0c;实际上是由于我自己编译的ffmpeg时候&#x…...

《数字图像处理基础》学习01-数字图像处理的相关基础知识

这篇文章只是对数字图像处理的相关基础知识有个大概的了解&#xff0c;之后的文章会接着补充和扩展。 目录 一&#xff0c;图像的基本概念 1&#xff0c;图像 2&#xff0c;图像的分类 1&#xff09;物理图像 2&#xff09;虚拟图像 二&#xff0c;数字图像处理 三&…...

C#-泛型学习笔记

C#泛型——约束|协变|逆变 1、泛型使用 在生命时可以使用<>&#xff0c;可以写一个标识符代替一些数据类型&#xff0c;在声明时给出明确定义。 非常强大&#xff0c;因此需要约束。 2、泛型约束 where T: struct//值类型约束&#xff0c;要求泛型必须为基本数据类型…...

Java第二阶段---11封装---第四节 static 修饰符

1.static 修饰符应用范围 static修饰符只能用来修饰类中定义的成员变量、成员方法、代码块以及内部类(内部类有专门章节进行讲解)。 2.static 修饰成员变量 static 修饰的成员变量称之为类变量。属于该类所有成员共享。 示例 package cn.lyxq.test04;public class Chinese…...

【C/C++】错题记录(五)

题目一 题目二 在 16 位机器上&#xff0c;通常以 2 字节为边界对齐。 首先看 char a&#xff0c;它占用 1 个字节。接着是 int b&#xff0c;占用 2 个字节。由于要满足边界对齐&#xff0c;在 char a后面会填充 1 个字节&#xff0c;使得 int b从 2 字节边界开始存储。最后是…...

关系数据库标准语言SQL(11,12)

目录 带有EXISTS谓词的子查询 exists谓词 例子 not exists谓词 例子 不同形式的查询间的替换 用EXISTS/NOT EXISTS实现全称量词 用EXISTS/NOT EXISTS:实现逻辑蕴涵 集合查询 并操作UNION 交操作INTERSECT 差操作EXCEPT 基于派生表的查询 select语句的基本格式 带有…...

Oracle 11g RAC 节点异常重启问题分析

一、背景 在国庆期间巡检的时候&#xff0c;发现数据库alert日志中出现了异常重启的信息&#xff0c;当即对该报错进行分析处理。 二、处理过程 &#xff08;1&#xff09;数据库告警日志分析 node1 alert&#xff1a; Sat Oct 05 13:05:14 2024 Thread 1 advanced to log …...

vscode 中显示 pnpm : 无法加载文件 C:\Users\AppData\Roaming\npm\pnpm.ps1,因为在此系统上禁止运行脚本

vscode中运行pnpm报错 pnpm : 无法加载文件 C:\Users\AppData\Roaming\npm\pnpm.ps1&#xff0c;因为在此系统上禁止运行脚本 解决办法如下 1、用 get-ExecutionPolicy 命令在vscode终端查询状态 如果返回的是 Restricted &#xff0c;则说明是禁止的 2、用 set-ExecutionPolic…...

C嘎嘎入门篇:类和对象番外(时间类)

前文&#xff1a; 小编在前文讲述了类和对象的一部分内容&#xff0c;其中小编讲述过运算符重载这个概念以及一个时间类&#xff0c;当时小编讲的没有那么细致&#xff0c;下面小编将会讲述时间类来帮助各位读者朋友更好的去理解运算符重载&#xff0c;那么&#xff0c;代码时刻…...

Spring Boot项目实战教程:快速构建Web应用与RESTful API

目录 一、Spring Boot简介1、Spring Boot的定义2、Spring Boot的优势&#xff08;1&#xff09;快速开发&#xff08;2&#xff09;自动配置&#xff08;3&#xff09;微服务支持&#xff08;4&#xff09;无代码生成和XML配置&#xff08;5&#xff09;独立运行&#xff08;6&…...

label-studio的使用教程(导入本地路径)

文章目录 1. 准备环境2. 脚本启动2.1 Windows2.2 Linux 3. 安装label-studio机器学习后端3.1 pip安装(推荐)3.2 GitHub仓库安装 4. 后端配置4.1 yolo环境4.2 引入后端模型4.3 修改脚本4.4 启动后端 5. 标注工程5.1 创建工程5.2 配置图片路径5.3 配置工程类型标签5.4 配置模型5.…...

.Net框架,除了EF还有很多很多......

文章目录 1. 引言2. Dapper2.1 概述与设计原理2.2 核心功能与代码示例基本查询多映射查询存储过程调用 2.3 性能优化原理2.4 适用场景 3. NHibernate3.1 概述与架构设计3.2 映射配置示例Fluent映射XML映射 3.3 查询示例HQL查询Criteria APILINQ提供程序 3.4 高级特性3.5 适用场…...

可靠性+灵活性:电力载波技术在楼宇自控中的核心价值

可靠性灵活性&#xff1a;电力载波技术在楼宇自控中的核心价值 在智能楼宇的自动化控制中&#xff0c;电力载波技术&#xff08;PLC&#xff09;凭借其独特的优势&#xff0c;正成为构建高效、稳定、灵活系统的核心解决方案。它利用现有电力线路传输数据&#xff0c;无需额外布…...

全球首个30米分辨率湿地数据集(2000—2022)

数据简介 今天我们分享的数据是全球30米分辨率湿地数据集&#xff0c;包含8种湿地亚类&#xff0c;该数据以0.5X0.5的瓦片存储&#xff0c;我们整理了所有属于中国的瓦片名称与其对应省份&#xff0c;方便大家研究使用。 该数据集作为全球首个30米分辨率、覆盖2000–2022年时间…...

第25节 Node.js 断言测试

Node.js的assert模块主要用于编写程序的单元测试时使用&#xff0c;通过断言可以提早发现和排查出错误。 稳定性: 5 - 锁定 这个模块可用于应用的单元测试&#xff0c;通过 require(assert) 可以使用这个模块。 assert.fail(actual, expected, message, operator) 使用参数…...

【OSG学习笔记】Day 16: 骨骼动画与蒙皮(osgAnimation)

骨骼动画基础 骨骼动画是 3D 计算机图形中常用的技术&#xff0c;它通过以下两个主要组件实现角色动画。 骨骼系统 (Skeleton)&#xff1a;由层级结构的骨头组成&#xff0c;类似于人体骨骼蒙皮 (Mesh Skinning)&#xff1a;将模型网格顶点绑定到骨骼上&#xff0c;使骨骼移动…...

华为云Flexus+DeepSeek征文|DeepSeek-V3/R1 商用服务开通全流程与本地部署搭建

华为云FlexusDeepSeek征文&#xff5c;DeepSeek-V3/R1 商用服务开通全流程与本地部署搭建 前言 如今大模型其性能出色&#xff0c;华为云 ModelArts Studio_MaaS大模型即服务平台华为云内置了大模型&#xff0c;能助力我们轻松驾驭 DeepSeek-V3/R1&#xff0c;本文中将分享如何…...

python报错No module named ‘tensorflow.keras‘

是由于不同版本的tensorflow下的keras所在的路径不同&#xff0c;结合所安装的tensorflow的目录结构修改from语句即可。 原语句&#xff1a; from tensorflow.keras.layers import Conv1D, MaxPooling1D, LSTM, Dense 修改后&#xff1a; from tensorflow.python.keras.lay…...

Linux C语言网络编程详细入门教程:如何一步步实现TCP服务端与客户端通信

文章目录 Linux C语言网络编程详细入门教程&#xff1a;如何一步步实现TCP服务端与客户端通信前言一、网络通信基础概念二、服务端与客户端的完整流程图解三、每一步的详细讲解和代码示例1. 创建Socket&#xff08;服务端和客户端都要&#xff09;2. 绑定本地地址和端口&#x…...

安宝特案例丨Vuzix AR智能眼镜集成专业软件,助力卢森堡医院药房转型,赢得辉瑞创新奖

在Vuzix M400 AR智能眼镜的助力下&#xff0c;卢森堡罗伯特舒曼医院&#xff08;the Robert Schuman Hospitals, HRS&#xff09;凭借在无菌制剂生产流程中引入增强现实技术&#xff08;AR&#xff09;创新项目&#xff0c;荣获了2024年6月7日由卢森堡医院药剂师协会&#xff0…...