An easy mistake, been there.. too many times actually :)
I would explain it like this:
GameObject is a type. The type GameObject can only be associated with GameObjects or things that inherits from GameObject.
The meaning of this is: The GameObject variable can only point to GameObjects and subclasses of the GameObject. The code down below is pointing to a Component which is of type GameObject.
GameObject.Find("Cubey").GetComponent<GameObject>();
The code says "Find Cubey and point to a GameObject attached to Cubey".
I guess as already said above that the Component You are looking for is not of the type GameObject.
If you would like the variable GameObject myCube to point to Cubey you could do:
GameObject myCube;
void Start(){
// Lets say you have a script attached called Cubey.cs, this solution takes a bit of time to compute.
myCube = GameObject.FindObjectOfType<Cubey>();
}
// This is a usually a better approach, You need to attach cubey through the inspector for this to work.
public GameObject myCube;
Hope that helps anyone coming to this post with the same problem.
GameObjects - you are trying to assign the value ofGetComponent<T>toGameObject- surely you want aGameComponentorComponent(or whatever the equivalent is in Unity) - Charleh