gameobject references runtime script in scene file

I added some UI components to my scene and now I keep getting this error whenever I try to run the game. What does this error even mean, the exact line in the reads

GameObject (named 'Canvas') references runtime script in scene file. Fixing!

which tells me that the object in the scene is using runtime scripts (which would make sense to be doing at runtime) and that it’s fixed whatever problem it was having (obviously not, as the game still does not run).

I also get a ton of warnings saying that scripts are missing on objects (core scripts that are part of Unity), even though these scripts are still showing in the inspector without any issues.

Anyone else encounter this problem and have a solution?

Possibly not the only time you would see this error, but you will see it if you have a script attached to a Game Object and you decide to remove its inheritance to MonoBehaviour (e.g. because you don’t need it)

It becomes a “Runtime” script which (most likely) should have not been attached to a Game Object to begin with.

Maybe in this occasion the Game Object named “Canvas” contains an attached script to it which does not extend MonoBehaviour or ScriptableObject.

I used Assets/Reimport All and it was fixed

This may be an old thread but I had the same issue and I found on a chinese blog I think that the problem was that one of my scripts didn’t inherit MonoBehaviour.

I noticed this happened to me whenever i tried creating a world space ui.
Deleting it removed the errors. Creating a new one created the same ones as before.

In the end I backed up my project and fixed it by clicking Assets>Reimport All and the UIs and everything else worked fine.

My only solution was to go back to a backup of the project that I had made two days earlier, and to re-do the tasks that we had recorded in the worklogs across that time. We worked on this for 2 solid days, that was the solution.

It just happened to me and all i did was copy all the assets to a new project and it works fine.
Hope this helps

Don’t reinstall, don’t make a new class. The problem is that you have a class in a wrong folder or you are not inheriting from the right base.

In some cases you have a regular class sat inside of your Editor folder, trying to inherit from Monobehaviour. In other cases you put your class inside a regular folder, on a GameObject in the scene and you are not inheriting from Mono.

This error should be easy to resolve if you can locate the script/class that is either in the Editor folder and should not be there, or find the class that is in your scene without Monobehaviour.

Use Assets / Reimport All.
Worked absolutely well for me.

Hope it helps you. :slight_smile:

This happened to me when I spelled MonoBehaviour as MonoBehavior. It didn’t cause an error in Visual Studio (strangely), but did present that very confusing message in the console.

Reimporting all fixed those.But I found that no layout components working on that situation. Some problem with UnityEngine.UI and Monobehaviour inheritance.Hope Unity will fix this.

Make sure you didn’t duplicate ‘EventSystem’ by mistake, that was my problem. Also check for any missing references in the Input Field’s… well, fields. :slight_smile:

In my case I put a script in an editor folder, which was also attached to the game object.

Hi I have the same problem when load the assetbundle the error code as follows:
The referenced script on this Behaviour(GameObject ‘SystemChannelB’) is missing!

A script behaviour(script unknown or not yet loaded)has a different serialization layout when loading.(Read 32 bytes but expected 56 bytes) Did you #iddef UNITY_EDITOR a section
of your serialized properties in your scripts?

Prefab has mulitiple Transform components! removing them automatically would not be safe

GameObject(named ‘SystemChannelB’)references runtime script in scene file.Fixing!

My sololution is find the loaded AssetBundle (which is a prefab) an find where is the SystemChannelB , as a result ,i find there is a script refer to SystemChannelB but,noSystemChannelB object, so,I delete the SystemChannelB refer an rebuild AssetBundle an loade . finally the error is gone. my english is so poor, i hope express myself.

I had the same problem.

My solution: I had a prefab that had a prefab that was using the scripts that I removed the inheritance to monobehaviour. This was irritating as f… but after I removed that prefab all the errors went away.

I had this problem because I had a Script in my “Editor” folder by mistake. Any Scripts in the “Editor” folder can only be scripts that affect the UNITY UI and nothing in the Scene (nothing in the game itself). Scripts from the “Editor” folder cannot be applied to game objects.