Example #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////
        protected static void Create(Transform parent, Picker instance, int buttonCount)
        {
            var lockerPrefab = Resources.Load <GameObject>("Submarine/Build/SmallLocker");
            var textPrefab   = Instantiate(lockerPrefab.GetComponentInChildren <Text>());

            textPrefab.fontSize = 16;
            textPrefab.color    = ScreenContentColor;

            float padding  = 30;
            float width    = padding + instance.ButtonSize + ((instance.ButtonsPerRow - 1) * instance.Spacing) - 20;
            int   rowCount = Mathf.CeilToInt(instance.ButtonsPerPage / (float)instance.ButtonsPerRow);
            float height   = padding + instance.ButtonSize + ((rowCount - 0.5f) * instance.Spacing);

            var rt = instance.rectTransform;

            RectTransformExtensions.SetParams(rt, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), parent);
            RectTransformExtensions.SetSize(rt, width, height);

            instance.background      = instance.gameObject.AddComponent <Image>();
            instance.background.type = Image.Type.Sliced;
            instance.background.rectTransform.anchoredPosition = new Vector2(0, -20);

            instance.pageText = LockerPrefabShared.CreateText(instance.transform, textPrefab, Color.white, 0, 10, "X/X");
            RectTransformExtensions.SetSize(instance.pageText.rectTransform, 30, 20);

            for (int i = 0; i < buttonCount; ++i)
            {
                var colorButton = ColorPickerButton.Create(instance.transform, instance.ButtonSize, instance.ButtonSize * 0.7f);
                instance.buttons.Add(colorButton);
            }

            instance.prevPageButton = ColorPickerPageButton.Create(instance.transform, Color.white);
            instance.nextPageButton = ColorPickerPageButton.Create(instance.transform, Color.white);
        }
Example #2
0
        /*__________________________________________________________________________________________________________*/

        protected static void Create(Transform parent, Picker colorGrid, int buttonCount, GameObject lockerPrefab = null)
        {
#if SUBNAUTICA
            lockerPrefab = Resources.Load <GameObject>("Submarine/Build/SmallLocker");
            var textPrefab = Instantiate(lockerPrefab.GetComponentInChildren <Text>());
#elif BELOWZERO
            var textPrefab = Instantiate(lockerPrefab.GetComponentInChildren <TextMeshProUGUI>());
#endif

            textPrefab.fontSize = 12;
            textPrefab.color    = ScreenContentColor;

            float padding  = 10;
            float width    = padding + colorGrid.ButtonSize + (colorGrid.ButtonsPerRow * colorGrid.Spacing);
            int   rowCount = Mathf.CeilToInt(colorGrid.ButtonsPerPage / (float)colorGrid.ButtonsPerRow);
            float height   = 20 + colorGrid.ButtonSize + ((rowCount - 0.5f) * colorGrid.Spacing);

            var rt = colorGrid.rectTransform;
            // The first Vector2 positions the colorGrid on the locker horz / vert.
            RectTransformExtensions.SetParams(rt, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.6f), parent);
            RectTransformExtensions.SetSize(rt, width, height);

            colorGrid.background        = colorGrid.gameObject.AddComponent <Image>();
            colorGrid.background.sprite = ImageUtils.LoadSprite(Mod.GetAssetPath("Background.png"));
            colorGrid.background.color  = new Color(1, 1, 1);

            for (int i = 0; i < buttonCount; ++i)
            {
                var colorButton = ColorPickerButton.Create(colorGrid.transform, colorGrid.ButtonSize, colorGrid.ButtonSize * 0.7f);
                colorGrid.buttons.Add(colorButton);
            }
        }