Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question image change color does not work

Discussion in 'Scripting' started by juan_589migue, Apr 17, 2023.

  1. juan_589migue

    juan_589migue

    Joined:
    Dec 31, 2020
    Posts:
    9
    Hi guys, i have this script, and debugin logs that show to me that in fact the color image is changing but when i run it it dsent change the color of the inputs.
    Please help me!!
    Here the code

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using TMPro;
    6.  
    7. public class ValidateLoginButtom : MonoBehaviour
    8. {
    9.     [SerializeField] public TMP_InputField UserInput, passWordInput, NewpassWordInput, ConfirmPassWordInput, NewNameInput, NewEmailInput, NewPhone;
    10.     [SerializeField] public Button EntrarButton, NextButton, CreateButtom;
    11.     [SerializeField] Image emailImage, confirmNewPasswordImage;
    12.  
    13.     public bool emailIsOk, passWordIsOk = false;
    14.  
    15.  
    16.  
    17.     private void Update()
    18.     {
    19.         if (UserInput.text != "" && passWordInput.text != "")
    20.         {
    21.             EntrarButton.interactable = true;
    22.         }
    23.        
    24.    else if (NewpassWordInput.text != "" && ConfirmPassWordInput.text != "" && NewNameInput.text != "" && NewEmailInput.text != "" && NewPhone.text != "" && emailIsOk == true && passWordIsOk == true)
    25.         {
    26.             NextButton.interactable = true;
    27.         }
    28.         else
    29.         {
    30.             NextButton.interactable = false;
    31.             EntrarButton.interactable = false;
    32.         }
    33.  
    34.  
    35.     }
    36.  
    37.     public void emailChecker()
    38.     {
    39.         if (NewEmailInput.text.IndexOf("@") > 0 && NewEmailInput.text.IndexOf(".") > 0)
    40.         {
    41.             emailIsOk= true;
    42.          
    43.  
    44.          
    45.         }
    46.         else
    47.         {
    48.             emailIsOk = false;
    49.             emailImage.color = new Color(215, 195, 195, 255);
    50.            
    51.            
    52.         }
    53.         // Debug.Log(emailIsOk);
    54.         Debug.Log("the email color is:" + NewEmailInput.image.color);
    55.     }
    56.  
    57.     public void passWordChecker()
    58.     {
    59.         if ( NewpassWordInput.text == ConfirmPassWordInput.text)
    60.         {
    61.             passWordIsOk = true;
    62.        
    63.  
    64.         }
    65.         else
    66.         {
    67.             passWordIsOk = false;
    68.            confirmNewPasswordImage.color = new Color(215, 195, 195, 255);
    69.  
    70.         }
    71.        Debug.Log("the pasword color is:" + ConfirmPassWordInput.image.color);
    72.     }
    73. }
    74.  
    the debug log says to me that the color is changing but it still is white.
    Help!!!! and thank you
    upload_2023-4-17_17-43-51.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,768
    Last edited: Apr 18, 2023
  3. juan_589migue

    juan_589migue

    Joined:
    Dec 31, 2020
    Posts:
    9
    Hey Kurt!! i owe you one!! that just work after hours and hours. Thank you thank you very much!!!
     
    Kurt-Dekker likes this.