Component MonoBehaviour could not be loaded

Hi all,

I have a simple prefab which contains a cube GameObject. It did have a script attached, but I removed it just in case it was the problem.

The console gives me the following error (at build time):

Component MonoBehaviour could not be loaded when loading game object. Cleaning up!

With a whole bunch more data.

There are no instances of this prefab in the hierarchy.

Any ideas?

did you by error name your class MonoBehaviour?

My prefab is called ‘Tile’, and only contaisn a Cube with default material, renderer etc.

I also have a C# script called ‘Tile’. Would this cause problems? (Prefab name and script name being the same)?

using UnityEngine;
using System.Collections;

public class Tile : MonoBehaviour {
	public int tileX = 0;
	public int tileY = 0;
	public bool dragging = false;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

However, the error seems to be on the Prefab, not the Script.

Actually, this error does not seem to be attached to any prefab or script in my project. It just seems to be a general error.

Here is more information on the error:

Component MonoBehaviour could not be loaded when loading game object. Cleaning up!
UnityEditor.SerializedObject:.ctor(Object)
UnityEditor.SerializedObject:.ctor(Object)
UnityEditor.Editor:GetOptimizedGUIBlockImplementation(Boolean, Boolean, OptimizedGUIBlock, Single)
UnityEditor.GenericInspector:GetOptimizedGUIBlock(Boolean, Boolean, OptimizedGUIBlock, Single)
UnityEditor.InspectorWindow:OnGUI()
System.Reflection.MonoMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoMethod:InternalInvoke(Object, Object[])
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
UnityEditor.HostView:Invoke(String)
UnityEditor.DockArea:OnGUI()

[..\..\Runtime\BaseClasses\GameObject.cpp line 417]

Please can you file a bug report for this (menu: Help > Report A Problem), especially if this is occurring with the beta version of Unity. It may be something in your project that is causing this, but it might instead be some code within Unity itself.

I just had the same error about a RigidBody in Unity 4.3.4f1.

Removing and re-adding the RigidBody to my prefab solved the problem.

I’m not sure what caused it. Good luck!

1 Like