# find all objects

**URL:** https://discussions.unity.com/t/find-all-objects/494305
**Category:** Scripting
**Tags:** Scripting
**Created:** [January 7, 2013, 12:53pm UTC](https://discussions.unity.com/t/find-all-objects/494305 "2013-01-07T12:53:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Dimarik](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@Dimarik](https://discussions.unity.com/u/Dimarik)
#### Post date: [January 7, 2013, 12:53pm UTC](https://discussions.unity.com/t/find-all-objects/494305/1 "2013-01-07T12:53:09Z")

</div>

Hi! I create objects by using Prefab at script CarScriptCreate.cs. Prefab called CarPrefabType1.  
At another Script I want to tind all cars which has created by CarScriptCreate.cs.  
I tryed to do this:

```auto
public CarPrefabType1 car1_object;
private CarPrefabType1 [] carObjects;
	// Use this for initialization
	void Start () 
	{
		carObjects= FindObjectsOfType(typeof(CarPrefabType1 ));
	
	}

```

But I can’t drag prefab into field CarPrefabType1 in the inspector because it isn’t shown. I don’t know why unity dont show this field. Compieler only writes that it doesn’t know this type. But I can’t attach this prefab to this script. I doing somethis wrong.

Please, tell me how I can find all objects which have created by another script by using Instantiate function.

---

<div class="post-metadata">

### Author: ![Dimarik](https://avatars.discourse-cdn.com/v4/letter/d/ea5d25/32.png) [@Dimarik](https://discussions.unity.com/u/Dimarik)
#### Post date: [January 7, 2013, 1:52pm UTC](https://discussions.unity.com/t/find-all-objects/494305/2 "2013-01-07T13:52:43Z")

</div>

Also I tryed to find objects by using function GameObject.FindGameObjectsWithTag(“CarPrefabType1”);  
But in the Debug.Log I saw that  
Unity Exception: Tag: CarPrefabType1 is not defined!  
What should I do?

---

<div class="post-metadata">

### Author: ![bigmisterb](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/bigmisterb/32/406611_2.png) [@bigmisterb](https://discussions.unity.com/u/bigmisterb)
#### Post date: [January 7, 2013, 4:39pm UTC](https://discussions.unity.com/t/find-all-objects/494305/3 "2013-01-07T16:39:55Z")

</div>

Try:

c#: GameObject.GetComponents();  
js: GameObject.GetComponents(CarScriptCreate);

> **[Unity - Scripting API: GameObject.GetComponents](https://docs.unity3d.com/ScriptReference/GameObject.GetComponents.html)**

If these objects do not have a CarScriptCreate, they should have a script on it that defines the base.

If they have no script. You could just keep track of what you have created in an array (or array list)
