C#(Unity)循环遍历Dictionary,并修改内容或删除内容

头文件

csharp 复制代码
using System.Linq;

代码

csharp 复制代码
/// <summary>
/// RotateObjectList :旋转列表 <物体本身,(Y轴当前旋转值,Y轴旋转目标)>
/// </summary>
Dictionary<HLSceneObject, (float,float)> RotateObjectList = new Dictionary<HLSceneObject,(float, float)>();

update(){
	// 物体旋转列表遍历
	if (RotateObjectList.Count > 0)
	{
	    for (int i = 0; i < RotateObjectList.Count; i++)
	    {
	        var item = RotateObjectList.ElementAt(i);
	        
	        float value = item.Value.Item1;
	        if (...)   
	        {
	            // 旋转
	            value += rotateDirection * ScrollAnglePerTime * time * 5;
	            item.Key.RotateObject(value);
	            // 写回
	            RotateObjectList[item.Key] = (value, item.Value.Item2);
	            // 判断是否结束
	            if (...)   
	            {
	                item.Key.ChangeRotate((int)item.Value.Item2);
	                OnScrolled();
	                RotateObjectList.Remove(item.Key);
	                continue;
	            }
	        }
	    }
	} 

}
相关推荐
唐青枫2 天前
别再乱用 StartNew:C#.NET TaskFactory 任务调度实战详解
c#·.net
Artech2 天前
[MAF预定义的AIContextProvider-03]ChatHistoryMemoryProvider——赋予Agent从经验中学习的能力
ai·c#·agent·memory·maf
Scout-leaf4 天前
C#摸鱼实录——IoC与DI案例详解
c#
咕白m6254 天前
使用 C# 在 Excel 中应用多种字体样式
后端·c#
Artech4 天前
[MAF预定义的AIContextProvider-02]AgentSkillsProvider——将Agent Skills引入MAF
ai·c#·agent·agent skills·maf
LDR0065 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术5 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript
码云数智-园园5 天前
C++20 Modules 模块详解
java·开发语言·spring
swordbob5 天前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio
源分享5 天前
Java线程同步的多种实现方法(非常详细)
java·开发语言·jvm