Unity freeze

Hey so I’m trying to program a special power into my game i like to call the spirit meter The first basic function of this meter allows players to see invisible objects
Spirit Meter

 using UnityEngine;
 using System.Collections;

 public class SpiritMeter : MonoBehaviour {

	public static float spirit = 10.0f;
	GUIText SpiritGUI;
	
	// Update is called once per frame
	void Update () {
 guiText.text = spirit.ToString();
	}
}

Invisible

using UnityEngine;
using System.Collections;

public class Invisible : MonoBehaviour {

public static bool invisible;	
	// Update is called once per frame
	void Update () {
	 invisible = true;
		if (invisible == true) 
		{
		renderer.enabled = false;
		}
	
		if (invisible == false)
		{
		renderer.enabled = true;
			}		
	}
}

Power1

using UnityEngine;
using System.Collections;

public class Power1 : MonoBehaviour {
	
	// Update is called once per frame
	
	void Update () {
		if (Input.GetKeyDown(KeyCode.G)){
			while (SpiritMeter.spirit == 10.0f){
				Invisible.invisible = false;
			}
		}
	}
}

When ever I press the set key of G unity as a whole freezes and I have to restart unity what’s wrong?

Unity isn’t crashing, it’s just executing your while loop. Since this loop has no way to ever end, it’s sits there consuming all the CPU, so you think Unity has crashed. This is called an infinite loop.