I have a basic scene with a 2D Rigidbody sprite and a controller script.
When I run my scene, I get the titled error, which makes one think the object is not assigned to the script in the inspector; however, it IS in fact assigned and there is nothing else that it should be assigned to.
What would cause such a basic scene to throw this message incorrectly? I have tried reassigning the object, I have deleted the script and recreated it and then reassigned it. No matter what I've done, it still throws the message.
This error wasn't showing up previously, and things worked as expected, but I can't think of what might have changed to give me this problem.
Answer by AmazingRuss
Mar 20 at 09:07 PM
I'm also getting this. If I print the field immediately before making the call, the console shows that it is not null. If I hit error pause, when I get the error, I can also see in the inspector that the value is assigned, and that the prefab exists.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
4 People are following this question.
Something Wrong With My Script
Melee Script Help
Melee script help
An object reference is required to access non-static member `UnityEngine.Component.GetComponent(System.Type)