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(int id, UICombox control) { var config = VideoSettingConfigManager.GetInstance().GetItemById(id); var defaultList = config.LevelDatas; var defaultValue = config.DefaultValue; int defaultIndex = defaultList.FindIndex((val) => Math.Abs(val - defaultValue) < 0.0000001); control.SetSelectByIndex(defaultIndex); }
private void InitCombox(int id, UICombox control, bool isDefault = true) { if (!_sendValList.ContainsKey(id) && !isDefault) { return; } var config = VideoSettingConfigManager.GetInstance().GetItemById(id); float curValue = isDefault ? config.DefaultValue : _sendValList[id]; var defaultList = config.LevelDatas; int defaultIndex = defaultList.FindIndex((val) => Math.Abs(val - curValue) < 0.0000001); control.SetSelectByIndex(defaultIndex); }
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); }