title: Unity assign GameObject to a prefab which is instantiated at run time
body: <p>I have a script called "trigger.cs". This script is attached to an object in a prefab. The prefab is instantiated at run time. </p>
  
  <p>Now this is what I want : <a href="https://i.stack.imgur.com/99cfl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/99cfl.png" alt="enter image description here"></a></p>
  
  <p>And this is the game object that I want to assign without drag and drop.<a href="https://i.stack.imgur.com/ioeAo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ioeAo.png" alt="enter image description here"></a></p>
  
  <p>Additionally, if I could somehow hard code the "Death Menu" that would also be a solution.</p>
  
  <p>Here is my trigger.cs file</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  
  public class trigger : MonoBehaviour {
  
  public Text scoreText;
  public Death deathMenu;
  
  //the line below is commented because its not working for me and just throws an error. 
  //public Death deathMenu = GameObject.Find("Death Menu");
  
  
  void Start(){
  }
  
  // Update is called once per frame
  void Update () {
      }
  
  
  void OnTriggerEnter (Collider othercollider){
      Debug.Log ("You Are Dead !");
      }
  }
  </code></pre>