示例#1
0
    void Awake()
    {
        // We need to do this in awake because in start which lightdark to use will be set

        // Get the theme
        currentTheme = ColorThemes.GetTheme(colorThemeName + "Theme");

        // Set all children's color which nee dto be set
        DarkLightColor xDL = transform.GetChild(0).GetComponent <DarkLightColor>();
        DarkLightColor oDL = transform.GetChild(1).GetComponent <DarkLightColor>();

        xDL.lightModeColor = currentTheme.xColorLight;
        xDL.darkModeColor  = currentTheme.xColorDark;

        oDL.lightModeColor = currentTheme.oColorLight;
        oDL.darkModeColor  = currentTheme.oColorDark;

        // Fields
        image              = GetComponent <Image>();
        rectTransform      = GetComponent <RectTransform>();
        eventTrigger       = gameObject.AddComponent <EventTrigger>();
        colorThemesHandler = transform.parent.GetComponent <ColorThemesUIHandler>();
    }
示例#2
0
    void Start()
    {
        // Log if something has been missed in unity explorer
        if (!bluetoothEnabledImage)
        {
            Debug.Log("Bluetooth enabled image missing!");
        }
        if (!startPanel)
        {
            Debug.Log("Start panel missing!");
        }
        if (!serverPanel)
        {
            Debug.Log("Server panel missing!");
        }
        if (!clientPanel)
        {
            Debug.Log("Client panel missing!");
        }
        if (!lobbyPanel)
        {
            Debug.Log("Lobby panel missing!");
        }

        InitGUI();

        bluetoothColors = bluetoothEnabledImage.GetComponent <DarkLightColor>();
        currentMode     = PreferencesScript.Instance.currentMode; // We only eed to get it here, because it can't change on this scene

        //TODO find out why we can't connect
        // Disable bluetooth because we can't connect to anything otherwise
        if (Bluetooth.Instance().IsEnabled())
        {
            Bluetooth.Instance().DisableBluetooth();
        }
    }
    /// <summary>
    /// Changes everything that we told it to to dark mode
    /// </summary>
    public void ChangeToDarkMode(float time)
    {
        for (int i = updateToColorModesImg.Count - 1; i >= 0; i--)
        {
            if (updateToColorModesImg[i] == null)
            {
                updateToColorModesImg.RemoveAt(i);
                continue;
            }

            DarkLightColor dlc = updateToColorModesImg[i].GetComponent <DarkLightColor>();

            if (dlc != null)
            {
                updateToColorModesImg[i].DOColor(dlc.darkModeColor, time);
            }
            else
            {
                updateToColorModesImg[i].DOColor(darkModeColor, time);
            }
        }

        for (int i = updateToColorModesTxt.Count - 1; i >= 0; i--)
        {
            if (updateToColorModesTxt[i] == null)
            {
                updateToColorModesTxt.RemoveAt(i);
                continue;
            }

            DarkLightColor dlc = updateToColorModesTxt[i].GetComponent <DarkLightColor>();

            // text is exactly opposite color
            if (dlc != null)
            {
                updateToColorModesTxt[i].DOColor(dlc.darkModeColor, time);
            }
            else
            {
                updateToColorModesTxt[i].DOColor(darkModeColor, time);
            }
        }

        for (int i = updateToColorTextMeshPro.Count - 1; i >= 0; i--)
        {
            if (updateToColorTextMeshPro[i] == null)
            {
                updateToColorTextMeshPro.RemoveAt(i);
                continue;
            }

            DarkLightColor dlc = updateToColorTextMeshPro[i].GetComponent <DarkLightColor>();

            // text is exactly opposite color
            if (dlc != null)
            {
                updateToColorTextMeshPro[i].DOColor(dlc.darkModeColor, time);
            }
            else
            {
                updateToColorTextMeshPro[i].DOColor(darkModeColor, time);
            }
        }
    }