The nested type `Find' does not exist in the type `UnityEngine.GameObject'

I get this error every time I use the Find or FindObjectsOfType. I just can’t figure this out. Is there something missing?

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class physicsScript : MonoBehaviour {
	

	GameObject[] objectList;
	int i;
	
	void Start () 
	{

	}
	
	void Update () 
	{
		//objectList = GameObject.FindObjectsOfType<physicsScript>();///
		//objectList = new GameObject.FindObjectsOfType<physicsScript>() as GameObject[];
		objectList = new GameObject.Find("GameObject") as GameObject[];
	}

1 Answer

1

You don’t have to say new in front of it, as that creates an instance. However, as far as I know, .Find will only return a single object, not an array

FindObjectsOfType returns an array of objects of that type, so if you search for physicsScript that’s what you get, not gameobjects:

   PhysicsScript[] scripts= FindObjectsOfType<PhysiscsScript>();

Didn't notice...thx

–