コード例 #1
0
        void InitPrepareItem()
        {
            var list = DataManager.Instance.gamePrepareData.preparePropertyDataList;

            var trans = Transform.FindTransfrom("Content/HardSetPanel/Content");

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].configType == 1)
                {
                    var item = ObjectManager.Instance.InstantiateObject(UIPath.PrefabPath.General_DropDownChooseItem);
                    if (item != null)
                    {
                        item.transform.SetParent(trans, false);
                        var itemTrans = item.transform.SafeGetComponent <DropDownChooseItem>();
                        var config    = PlayerModule.GetGamePrepareConfigItem(list[i].configID);
                        if (config != null)
                        {
                            List <GeneralDropDownChooseElement> elementList = new List <GeneralDropDownChooseElement>();
                            for (int j = 0; j < config.levelMap.Count; j++)
                            {
                                GeneralDropDownChooseElement element = new GeneralDropDownChooseElement
                                {
                                    index     = config.levelMap[j].Level,
                                    desc      = config.levelMap[j].strParam,
                                    linkParam = config.levelMap[j].hardLevelChange
                                };
                                elementList.Add(element);
                            }
                            itemTrans.SetUpItem(config.configID,
                                                config.configIconPath, config.configNameText, config.defaultSelectLevel,
                                                elementList);
                        }
                    }
                }
                else if (list[i].configType == 2)
                {
                    var item = ObjectManager.Instance.InstantiateObject(UIPath.PrefabPath.SliderSelectItem_Prepare);
                    if (item != null)
                    {
                        item.transform.SetParent(trans, false);

                        var config    = PlayerModule.GetGamePrepareConfigItem(list[i].configID);
                        var iconTrans = item.transform.FindTransfrom("Icon").SafeGetComponent <Image>().sprite = Utility.LoadSprite(config.configIconPath);
                        var nameTrans = item.transform.FindTransfrom("Text").SafeGetComponent <Text>().text = MultiLanguage.Instance.GetTextValue(config.configNameText);

                        var itemTrans = item.transform.FindTransfrom("GeneralSliderSelectItem").SafeGetComponent <SliderSelectItem>();
                        ///Init List

                        if (config != null)
                        {
                            List <GeneralSliderSelectElement> elementList = new List <GeneralSliderSelectElement>();
                            for (int j = 0; j < config.levelMap.Count; j++)
                            {
                                GeneralSliderSelectElement element = new GeneralSliderSelectElement
                                {
                                    showScaleSymbol = config.showScaleSymbol,
                                    index           = config.levelMap[j].Level,
                                    linkParam       = config.levelMap[j].hardLevelChange,
                                    value           = (float)config.levelMap[j].numParam
                                };
                                elementList.Add(element);
                            }

                            itemTrans.SetUpItem_GamePrepare(config.defaultSelectLevel, elementList, config.configID);
                        }
                    }
                }
            }
        }