Example #1
0
        void ResetAndLayout()
        {
            // Reset
            if (mainBubble == null)
            {
                mainBubble = this.GetComponentInChildren <GamesSelectorBubble>();
            }
            foreach (GamesSelectorBubble bubble in bubbles)
            {
                if (bubble != mainBubble)
                {
                    Destroy(bubble.gameObject);
                }
            }
            bubbles.Clear();

            // Layout
            const float bubblesDist = 0.1f;
            int         totBubbles  = games.Count;
            float       bubbleW     = mainBubble.Main.GetComponent <Renderer>().bounds.size.x;
            float       area        = totBubbles * bubbleW + (totBubbles - 1) * bubblesDist;
            float       startX      = -area * 0.5f + bubbleW * 0.5f;

            for (int i = 0; i < totBubbles; ++i)
            {
                MiniGameData        mgData = games[totBubbles - i - 1];
                GamesSelectorBubble bubble = i == 0 ? mainBubble : (GamesSelectorBubble)Instantiate(mainBubble, this.transform);
                bubble.Setup(mgData.GetIconResourcePath(), mgData.GetBadgeIconResourcePath(), startX + (bubbleW + bubblesDist) * i);
                bubbles.Add(bubble);
            }
        }
Example #2
0
        void ResetAndLayout()
        {
            // Reset
            if (mainBubble == null)
            {
                mainBubble = this.GetComponentInChildren <GamesSelectorBubble>();
            }
            foreach (GamesSelectorBubble bubble in bubbles)
            {
                if (bubble != mainBubble)
                {
                    Destroy(bubble.gameObject);
                }
            }
            bubbles.Clear();

            // Layout
            const float bubblesDist = 0.1f;
            int         totBubbles  = games.Count;
            float       bubbleW     = mainBubble.Main.GetComponent <Renderer>().bounds.size.x;
            float       area        = totBubbles * bubbleW + (totBubbles - 1) * bubblesDist;
            float       startX      = -area * 0.5f + bubbleW * 0.5f;

            //if (!LanguageSwitcher.LearningRTL) startX *= -1;

            for (int i = 0; i < totBubbles; ++i)
            {
                int iRTL = LanguageSwitcher.LearningRTL ? totBubbles - i - 1 : i;

                MiniGameData        mgData = games[iRTL];
                GamesSelectorBubble bubble = i == 0 ? mainBubble : (GamesSelectorBubble)Instantiate(mainBubble, this.transform);
                bubble.Setup(AppManager.I.AssetManager.GetMainIcon(mgData), AppManager.I.AssetManager.GetBadgeIcon(mgData), startX + (bubbleW + bubblesDist) * i);
                bubbles.Add(bubble);
            }
        }