Ejemplo n.º 1
0
        IEnumerator GenerateList()
        {
            Loading.SetActive(true);
            Layout.enabled     = true;
            SizeFitter.enabled = true;

            int GenerateCount = 0;

            for (int i = 0; i < FoundUnits.Count; i++)
            {
                GetGamedataFile.UnitDB UnitDB = GetGamedataFile.LoadUnitBlueprintPreview(FoundUnits[i]);

                GameObject NewButton = Instantiate(Prefab) as GameObject;
                NewButton.transform.SetParent(Pivot, false);
                ResourceObject NewResObject = NewButton.GetComponent <ResourceObject>();
                NewResObject.RawImages[0].texture = IconBackgrounds[UnitDB.Icon];
                NewResObject.RawImages[1].texture = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/" + UnitDB.CodeName + "_icon.dds", false, true, true);
                if (NewResObject.RawImages[1].texture == Texture2D.whiteTexture)
                {
                    NewResObject.RawImages[1].enabled = false;
                }
                NewResObject.InstanceId          = i;
                NewResObject.NameField.text      = UnitDB.CodeName;
                NewResObject.CustomTexts[0].text = SortDescription(UnitDB);
                NewResObject.CustomTexts[1].text = UnitDB.Name;
                NewButton.SetActive(CheckSorting(UnitDB));

                LoadedButtons.Add(NewResObject);
                LoadedUnits.Add(UnitDB);

                GenerateCount++;

                if (GenerateCount >= 7)
                {
                    GenerateCount = 0;
                    yield return(null);
                }
            }

            IsGenerated = true;

            yield return(null);

            Loading.SetActive(false);
            Layout.enabled     = false;
            SizeFitter.enabled = false;
            GeneratingList     = null;
            SortUnits();
        }