Exemple #1
0
    IEnumerator DoCreateDispensaryList()
    {
        int   counter      = 0;
        float prefabHeight = loadDifferentBuilding_dispensaryPrefab.gameObject.GetComponent <RectTransform>().rect.height;
        List <Dispensary_s> dispensaries = currentCompany.dispensaries;

        if (dispensaries == null)
        {
            yield break;
        }
        foreach (Dispensary_s dispensary in dispensaries)
        {
            UIObjectAnimator newAnimator = Instantiate(loadDifferentBuilding_dispensaryPrefab, loadDifferentBuilding_dispensaryPrefab.transform.position, loadDifferentBuilding_dispensaryPrefab.transform.rotation, mainDispensariesScrollablePanel.transform);
            newAnimator.gameObject.SetActive(true);
            newAnimator.name = dispensary.dispensaryName;
            Text[] texts = newAnimator.GetComponentsInChildren <Text>();
            texts[0].text = dispensary.dispensaryName;

            Vector2 prefabAnchorMin = loadDifferentBuilding_dispensaryPrefab.GetComponent <RectTransform>().anchorMin;
            Vector2 prefabAnchorMax = loadDifferentBuilding_dispensaryPrefab.GetComponent <RectTransform>().anchorMax;
            newAnimator.gameObject.SetActive(true);
            newAnimator.GetComponent <RectTransform>().anchorMin        = prefabAnchorMin + new Vector2(0, -prefabHeight / 14 * counter);
            newAnimator.GetComponent <RectTransform>().anchorMax        = prefabAnchorMax + new Vector2(0, -prefabHeight / 14 * counter);
            newAnimator.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -prefabHeight * counter);
            //newAnimator.transform.position = newAnimator.transform.position + new Vector3(0, -prefabHeight * (counter+3), 0);
            dispensaryUIAnimators.Add(newAnimator);
            newAnimator.OnScreen();
            counter++;
            yield return(new WaitForSeconds(.015f));
        }
    }
    IEnumerator DoCreateCareerSavegamesList()
    {
        int             counter      = 0;
        float           prefabHeight = careerSavegamePrefab.gameObject.GetComponent <RectTransform>().rect.height;
        List <SaveGame> saveGames    = database.GetCareerSaveGames();

        foreach (SaveGame save in saveGames)
        {
            UIObjectAnimator newAnimator = Instantiate(careerSavegamePrefab, careerSavegamePrefab.transform.position, careerSavegamePrefab.transform.rotation, mainCareerScrollablePanel.transform);
            newAnimator.gameObject.SetActive(true);
            newAnimator.name = saveGames[counter].company.companyName;
            Text[] texts = newAnimator.GetComponentsInChildren <Text>();
            texts[0].text = save.company.companyName;

            Vector2 prefabAnchorMin = careerSavegamePrefab.GetComponent <RectTransform>().anchorMin;
            Vector2 prefabAnchorMax = careerSavegamePrefab.GetComponent <RectTransform>().anchorMax;
            newAnimator.gameObject.SetActive(true);
            newAnimator.GetComponent <RectTransform>().anchorMin        = prefabAnchorMin + new Vector2(0, -prefabHeight / 14 * counter);
            newAnimator.GetComponent <RectTransform>().anchorMax        = prefabAnchorMax + new Vector2(0, -prefabHeight / 14 * counter);
            newAnimator.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -prefabHeight * counter);
            //newAnimator.transform.position = newAnimator.transform.position + new Vector3(0, -prefabHeight * (counter+3), 0);
            careerSavegameUIAnimators.Add(newAnimator);
            newAnimator.OnScreen();
            counter++;
            yield return(new WaitForSeconds(.015f));
        }
    }