using System.Collections; using System.Collections.Generic; using UnityEngine; using XRTool.Util; public class ConfigModel : UnitySingleton { /// /// 存储菜单项数据(链表结构) /// CircleList _itemLinklist = new CircleList(); /// /// 获取头节点(第一个数据) /// /// public DoubleLinkNode GetFirstMenuItem() { return _itemLinklist.First; } /// /// 获取尾节点(最后一个数据) /// /// public DoubleLinkNode GetLastMenuItem() { return _itemLinklist.Last; } /// /// 添加数据 /// public void AddElement(RoomConfig itemConfig) { if (itemConfig.Id == "") { _itemLinklist.AddNode(itemConfig); } else { DoubleLinkNode _node = _itemLinklist.First; while (_node.PreNode != _itemLinklist.First) { if (_node.Value.Id == "") { _node.Value = itemConfig; break; } } } } /// /// 读取数据 /// /// public void InitElement(RoomConfig itemConfig) { _itemLinklist.AddNode(itemConfig); } /// /// 删除指定的节点 /// /// public void RemoveElement(DoubleLinkNode ic) { _itemLinklist.RemoveNode(ic); } /// /// 数据的数量 /// /// public int Count { get { return _itemLinklist.Count; } } /// /// 清除所有数据 /// public void Clear() { _itemLinklist.Clear(); } }