A
A
Andrey2020-09-27 15:14:28
Unity
Andrey, 2020-09-27 15:14:28

How to set input field color?

Good afternoon. I know that the following code is wrong, because I assign different data types, but I think this code sets out the essence of the issue quite clearly.
It is necessary in the course of work to change the color (normalColor, highlightedColor) of the Input Field depending on the change of the player.

if(player_red == true)
        {
            for(int i = 0; i < 4; i++)
            {
                for(int j = 0; j < 4; j++ )
                {
                    var color_field = field[i,j].GetComponent<ColorBlock>();
                    color_field.normalColor = Color.red;
                    field[i,j] = color_field;
                }
            }
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Loli E1ON, 2020-09-27
@E1ON

normalColor can be changed through the Image component
inputField.image.color = Color.red;

A
Andrey, 2020-09-27
@officialandrey

ColorBlock cell = field[i,j].colors;
cell.highlightedColor = PlayerStyle();
cell.pressedColor = PlayerStyle();
cell.selectedColor = PlayerStyle();
field[i,j].colors = cell;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question