Mimic Update Function in Custom Function via while loop?

Lets say I like the way Update exsecutes a line every frame. Or how Fixed update runs, But I wish to do this in a custom function via while loop. Unity craps out. One would think that a While loop would try to run every fame.

For instance.

//Want to turn this...
void Update(){
      Debug.Log("This is a frame");
}


//into this 
void mimicUpdate(){
     while(true){
         Debug.Log("This is a frame?");
     }
}

Unity dies when it tries to run this, but not in the update function. what is the difference?

For instance if I want to add a force to a rigidbody but to keep my script more organized, I wish to keep the directions in their own functions instead of putting them all in the FixedUpdate()

If you want your while loop or other logic to run over multiple frames you should use coroutines - that’s what they do:

   IEnumerator LikeUpdate() {
        while(true) {
             Debug.Log("This is a frame");
             yield return null;
        }
   }

   IEnumerator LikeFixedUpdate() {
         while(true) {
              yield return new WaitForFixedUpdate();
         }
   }

Starting these routines with StartCoroutine:

    StartCoroutine(LikeFixedUpdate());

Of course you can have multiple loops and logic in a coroutine that you can’t have in Update etc:

    IEnumerator MoreComplicated() {
          for(var i = 0; i < 10; i++) {
              while(someField < 100) {
                //Do something
                yield return null;
              }
              if(somethingElse>100) {
                  yield return StartCoroutine(SomeDifferentRoutine()); //Waits until this is complete
              }
          }
    }