private void InitCombox(VideoSetting config) { var comboxModel = GetNewControlWithTitle(_comboxModel, config.Description); var uiCombox = new UICombox(comboxModel); var cComboxDic = new Dictionary <string, object>(); int selectedIndex = -1; for (int i = 0; i < config.LevelDatas.Count; i++) { cComboxDic[config.LevelNames[i]] = config.Id + ":" + config.LevelDatas[i]; float targetVal; if (_sendValList.TryGetValue(config.Id, out targetVal)) { if (Math.Abs(config.LevelDatas[i] - targetVal) < 0.0001f) { selectedIndex = i; } } } uiCombox.RegisteComBox(cComboxDic); uiCombox.itemSelect = ComBoxItemClick; uiCombox.SetSelectByIndex(selectedIndex); //这里会报错,字典里已存在这个字段,看上去像是重复加载,为了进入游戏先临时修复 by wzq if (_uiControlDict.ContainsKey(config.Id)) { Debug.LogError(config.Id + " is already in _uiControlDict"); _uiControlDict[config.Id] = uiCombox; } else { _uiControlDict.Add(config.Id, uiCombox); } }
private void InitCombox(VideoSetting config) { var comboxModel = GetNewControlWithTitle(_comboxModel, config.Description); var uiCombox = new UICombox(comboxModel); var cComboxDic = new Dictionary <string, object>(); int selectedIndex = -1; for (int i = 0; i < config.LevelDatas.Count; i++) { cComboxDic.Add(config.LevelNames[i], config.Id + ":" + config.LevelDatas[i]); float targetVal; if (_sendValList.TryGetValue(config.Id, out targetVal)) { if (Math.Abs(config.LevelDatas[i] - targetVal) < 0.0001f) { selectedIndex = i; } } } uiCombox.RegisteComBox(cComboxDic); uiCombox.itemSelect = ComBoxItemClick; uiCombox.SetSelectByIndex(selectedIndex); _uiControlDict.Add(config.Id, uiCombox); }