Color comparisons not working

Hi,

I’m making a simple fader that fades based on whatever color the guiTexture is, but I’m struggling to get the comparisons working.

My ‘Fade’ function currently has loads of different ways i’ve tried. But nothing seems to work. However if I just set the bool myself then it all works fine.

Here’s the script:

 void Start()
    	{
    		guiTexture.texture = blackScreenTexture;
    		guiTexture.color = Color.clear;
    	}

	void Update()
	{

		if (Input.GetKeyDown (KeyCode.E)) {

			Fade();
	
		}

		if (fadeToBlackBool)
			FadeToBlack ();

		if (fadeToClearBool)
			FadeToClear ();

	}

	void Fade()
	{

		if(guiTexture.color == Color.black)
			fadeToBlackBool = true;
		
		if(guiTexture.color == Color.clear)
			fadeToClearBool = true;

		if(guiTexture.color == new Color(0, 0, 0, 1))
			fadeToBlackBool = true;
		
		if(guiTexture.color == new Color(0, 0, 0, 0))
			fadeToClearBool = true;
		
		if(guiTexture.color.Equals(Color.black))
			fadeToBlackBool = true;

		if(guiTexture.color.Equals(Color.clear))
			fadeToClearBool = true;


		if(	(int)guiTexture.color.a == 1)
			fadeToBlackBool = true;
		
		if(	(int)guiTexture.color.a == 0)
			fadeToClearBool = true;


	}

	void FadeToBlack()
	{

		guiTexture.color = Color.Lerp (guiTexture.color, Color.black, .5f * Time.deltaTime);

		if (guiTexture.color.a >= .6f) {
			guiTexture.color = Color.black;
			fadeToBlackBool = false;		
		}

	}

	void FadeToClear()
	{
		
		guiTexture.color = Color.Lerp (guiTexture.color, Color.clear, .5f * Time.deltaTime);
		
		if (guiTexture.color.a <= .2f) {
			guiTexture.color = Color.clear;
			fadeToClearBool = false;		
		}

	}

Have you Debug.Log’ed the color you are checking against? My guess is that it’s just none of those colors.