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;
	            }
	        }
	    }
	} 

}
相关推荐
Android洋芋41 分钟前
AI辅助C盘清理
c语言·开发语言·人工智能·ai辅助c盘清理
灯澜忆梦2 小时前
Go 语言 _JSON---序列化与反序列化
开发语言·golang·json
麻瓜老宋2 小时前
AI开发C语言应用按步走,表达式计算器calc的第四步,交互式 REPL 模式
c语言·开发语言·atomcode
猫猫不是喵喵.3 小时前
双亲委派机制与类加载过程
java·开发语言
布朗克1683 小时前
Go入门到精通-22-同步原语
开发语言·后端·golang·同步原语
帅次3 小时前
Kotlin Flow 与 StateFlow:UI 单向数据流基础
开发语言·ui·kotlin·stateflow·onlifecycle
艾伦野鸽ggg3 小时前
JavaScript 浏览器本地存储
开发语言·javascript·ecmascript
杜子不疼.3 小时前
【Qt常用控件】WindowTitle 与 WindowIcon:窗口标题和图标
开发语言·qt
czhc11400756634 小时前
719:StartPoint;Margin;ResourceDictionar;Component.model;lds;
c#
玖玥拾4 小时前
Unity 3D 笔记(八)ScrollRect 滚动视图、NavMesh 自动寻路系统
笔记·3d·unity