Beispiel #1
0
    // Change the grid color for dark / light mode
    public static void SetGrid()
    {
        GameObject[] grid = GameObject.FindGameObjectsWithTag("background_block");


        for (int i = 0; i < grid.Length; i++)
        {
            MeshRenderer bgBlock  = grid[i].GetComponent <MeshRenderer>();
            Material[]   meshMats = bgBlock.materials;

            if (SetColor.GetDarkMode() == true)
            {
                meshMats[1] = null;
                meshMats[1] = SetColor.GetMaterial("Grid");
            }
            else
            {
                meshMats[1] = null;
                meshMats[1] = SetColor.GetMaterial("Grid");
            }

            bgBlock.materials = meshMats;
        }
    }
Beispiel #2
0
    void UpdateColor()
    {
        // Change BG
        var camera = (Camera)FindObjectOfType(typeof(Camera));

        camera.backgroundColor = SetColor.GetColor("Background");

        // Change Grid
        AnimateGrid.SetGrid();

        // Change Icon Color on highscore
        SpriteRenderer HighScoreIconRender = highScoreIcon.GetComponent <SpriteRenderer>();

        if (SetColor.GetDarkMode() == true)
        {
            HighScoreIconRender.color = SetColor.GetColor("Font");
        }
        else
        {
            HighScoreIconRender.color = SetColor.GetColor("Font");
        }

        // Change ChangeIconImage Image
        Image changeColorButtonImage = changeColorButton.GetComponent <Image>();

        //Debug.Log(changeColorButtonImage);

        if (SetColor.GetDarkMode() == true)
        {
            changeColorButtonImage.sprite = Resources.Load <Sprite>("Images/GridIconAlt");
        }
        else
        {
            changeColorButtonImage.sprite = Resources.Load <Sprite>("Images/GridIconDark");
        }

        // Change Labels
        GameObject[] labels = GameObject.FindGameObjectsWithTag("TextLabel");
        foreach (var a in labels)
        {
            MeshRenderer bgBlock  = a.GetComponent <MeshRenderer>();
            Material[]   meshMats = bgBlock.materials;

            if (SetColor.GetDarkMode() == true)
            {
                meshMats[0] = null;
                meshMats[0] = SetColor.GetMaterial("Grid");
            }
            else
            {
                meshMats[0] = null;
                meshMats[0] = SetColor.GetMaterial("Grid");
            }

            bgBlock.materials = meshMats;
        }

        // Changel Text on Labels
        GameObject[] textLabels = GameObject.FindGameObjectsWithTag("ScoreText");
        // Set UI Text to objects to access
        //Debug.Log(objs.Length);
        foreach (var i in textLabels)
        {
            var t = i.GetComponent <Text>();
            if (t.name.Equals("HighScore"))
            {
                if (SetColor.GetDarkMode() == true)
                {
                    t.color = SetColor.GetColor("Font");
                }
                else
                {
                    t.color = SetColor.GetColor("Font");
                }
            }
            if (t.name.Equals("CurrentScore"))
            {
                if (SetColor.GetDarkMode() == true)
                {
                    t.color = SetColor.GetColor("Font");
                }
                else
                {
                    t.color = SetColor.GetColor("Font");
                }
            }
        }
    }