title: How to delete selected object using button in unity
body: <p>I have two objects and one button. First I have to select one object and if I click the button then the selected object have to be destroyed. </p>
  
  <p>How I can destroy the object?</p>
  
  <p><strong>Coding to get seleced object name:</strong></p>
  
  <pre><code>public class ClickAction : MonoBehaviour {
      public string on = null;
      public Destroyer destroy;
  
      void Update() {
          if (Input.GetMouseButtonDown (0)) {
              Ray toMouse = Camera.main.ScreenPointToRay (Input.mousePosition);
              RaycastHit rhInfo;
              bool didHit = Physics.Raycast(toMouse, out rhInfo, 500.0f);
              if (didHit) {
                  Debug.Log(rhInfo.collider.name);
              }               
          }  
      } 
  }
  </code></pre>