Пример #1
0
    public void CreateTrophyObj(string name, string description, Sprite image, bool locked, GameObject container, int trophyNum, int trophyCount)
    {
        GameObject trophyObj = (GameObject)Instantiate(trophyPrefab);

        trophyObj.transform.SetParent(container.transform);
        trophyObj.transform.localScale = new Vector3(1, 1, 1);

        TrophyController trophyController = trophyObj.GetComponent <TrophyController>();

        trophyController.SetTrophyValues(name, description, image, locked);

        float width       = trophyObj.GetComponent <RectTransform>().rect.width;
        float startOffset = ((width / 2) - ((width / 2) * trophyCount));

        trophyObj.transform.localPosition = new Vector3(startOffset + (trophyNum * width), 0, 0);
    }