unity play code in editor code example

Example 1: stop unity editor playing

//C# public static class AppHelper
{     
  #if UNITY_WEBPLAYER     
    public static string webplayerQuitURL = "http://google.com";
  #endif     
    
  public static void Quit()     
  {         
    #if UNITY_EDITOR         
      UnityEditor.EditorApplication.isPlaying = false;                
    #endif     
    } 
}

Example 2: how to play animation with code in unity

public GameObject ExampleNPC;

void Update()
{
    if(Input.GetButtonDown("Animation")) // Make sure to refrence this in Input settings
    {
        ExampleNPC.GetComponent<Animator>().Play("Anim name");
    }
}