Error: "The type or namespace name `Ball' could not be found. Are you missing an assembly reference?"

I’ve been googling this error and the responses seem either over my head or not applicable. I’ve scoured the the discussion boards. I tried reinstalling Unity just to see if that might correct the error. Did I miss something in installing Unity 5 or switching it back over to MonoDevelop? I would greatly appreciate help on this one.

In writing the code MonoDevelop doesn’t like the declaration of “Ball” (turns red and on mouseover reads: "CS0103: The name ‘Ball’ does not exist in the current context’) and I get the following error in Unity:

Assets/Editor/CameraControl.cs(6,9): error CS0246: The type or namespace name `Ball’ could not be found. Are you missing an assembly reference?

using UnityEngine;
using System.Collections;

public class CameraControl : MonoBehaviour {

	public Ball ball;
	private Vector3 offset;

**It’s not solved in that I found a solution… a few days later I opened things up, and there was no problem in MonoDevelop, no error in Unity.


It’s hard to say without seeing the project, and knowing what you may have done in those days, however things that can cause this could be;

  • the class Ball not existing in your project
  • the class Ball being spelt differently, such as ball, C# is case sensitive
  • Unity being unable to compile your scripts (most likely), this could be because of an error elsewhere in your scripts

There was an issue with Visual Studio recently where it wouldnt re-load the project after changes were made within Unity, it could similar problems but as you said you were using MonoDevelop I don’t think this would apply.

Privacy & Terms