Here how do I attach the gameObject to the Script in Unity?
In Unity, I click on the script and to the right it says "None(GameObject)". Then as I click on the circle next to it, it doesn't show any game objects even though there are three in the scene. Can anyone tell me how to resolve this situation?
using UnityEngine; using System.Collections;
public class DestroyObject : MonoBehaviour {
public GameObject other;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.Space))
//gameObject.SetActive (false);
Destroy(other, 3.0f);
}
}
Answer by pandatree12 · Jan 31, 2017 at 07:28 PM
Try just dragging the object from the scene into the grey box in the inspector instead of clicking the circle.
Answer by TheRockRipper · Feb 01, 2017 at 12:45 AM
Thanks @pandatree12. I actually figured it out a few hours after posting the question. I just needed to have a Prefab.
Your answer
![](https://koobas.hobune.stream/wayback/20220612105922im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Have a GameObject to move only horizontally and not vertically 0 Answers
Disable and enable emission property of a material via C# script? 0 Answers
air hockey problem with independent controls 0 Answers
How to make GUI Text show number from another script 2 Answers
Reading Other Gameobject Collider 0 Answers