Example #1
0
    public void HandleColorThemeDropdown(Dropdown dropdown)
    {
        ColorTheme_SO theme = colorThemes[dropdown.value];

        fontColorDropdown.value = fontColors.IndexOf(theme.fontColor);
        SettingsController.Instance.SetUpColorTheme(theme);
    }
    public void SetUpColorTheme(ColorTheme_SO colorTheme)
    {
        tempColorTheme = colorTheme;

        SetUpFontColors(colorTheme.fontColor);
        ColorThemeChange.Invoke(colorTheme);
    }
    public void SetColorByTheme(ColorTheme_SO colorTheme)
    {
        switch (componentType)
        {
        case (ComponentType.BUTTON):
            if (buttonComponent == null)
            {
                Debug.LogWarningFormat("Component type {0} not set in UI object {1} ",
                                       componentType.ToString(), gameObject.name.ToString());
                return;
            }
            ColorBlock bc = buttonComponent.colors;
            bc.normalColor         = colorTheme.buttonColor;
            buttonComponent.colors = bc;
            break;

        case (ComponentType.SLIDER):
            if (sliderComponent == null)
            {
                Debug.LogWarningFormat("Component type {0} not set in UI object {1} ",
                                       componentType.ToString(), gameObject.name.ToString());
                return;
            }
            ColorBlock sc = sliderComponent.colors;
            sc.normalColor         = colorTheme.sliderColor;
            sliderComponent.colors = sc;
            break;

        case (ComponentType.DROPDOWN):
            if (dropdownComponent == null)
            {
                Debug.LogWarningFormat("Component type {0} not set in UI object {1} ",
                                       componentType.ToString(), gameObject.name.ToString());
                return;
            }
            ColorBlock dc = dropdownComponent.colors;
            dc.normalColor           = colorTheme.dropdownColor;
            dropdownComponent.colors = dc;
            break;

        case (ComponentType.IMAGE):
            if (imageComponent == null)
            {
                Debug.LogWarningFormat("Component type {0} not set in UI object {1} ",
                                       componentType.ToString(), gameObject.name.ToString());
                return;
            }
            imageComponent.color = colorTheme.imageColor;
            break;
        }
    }