x


Cannot assign GameObject in Inspector? [SOLVED]

//ButtonManager.js - Get user input from on-screen controls and pass along

var fireButton : GUITexture;
var actionButton : GUITexture;
var joyButton : GUITexture;
var actionOrient : GameObject;
var joyOrient : GameObject;
var actions = new GUITexture[4];
var destinations = new GameObject[4];
var feedback : GUIText;

As you can see, I have two variables, actionOrient and joyOrient, that are both GameObjects.

Cannot_assign_GO

Each variable is assigned properly in the Inspector; however, when I play my game I get the following error:

UnassignedReferenceException: The variable actionOrient of 'ButtonManager' has not been assigned. You probably need to assign the actionOrient variable of the ButtonManager script in the inspector. ButtonManager.Update () (at Assets/Scripts/ButtonManager.js:24)

I get a similar error for the joyOrient variable if I comment out the actionOrient line. What am I doing wrong here?

more ▼

asked Aug 28 '11 at 05:09 PM

noradninja gravatar image

noradninja
895 18 23 42

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Maybe the variables were something else, like Transform, when you assigned them? And then you changed them to GameObject later without reassigning the variables.

more ▼

answered Aug 28 '11 at 05:22 PM

Eric5h5 gravatar image

Eric5h5
102k 49 165 620

I wish this was the case, but its not. I Wrote the script as is, then drag/dropped the assignments in the Inspector. Perhaps it is time for me to export the project files to a bundle, make a new project, and reimport the bundle, when Unity is 'funky' to me, this usually fixes things right up.

Aug 28 '11 at 05:26 PM noradninja
(comments are locked)
10|3000 characters needed characters left

Turns out I had a duplicate copy of the script on the Main Camera. Deleted it and all is well again.

Facepalm.jpg

more ▼

answered Sep 24 '11 at 04:27 PM

noradninja gravatar image

noradninja
895 18 23 42

Facepalm x2 right here. Just had the same thing happen to me. Must've accidently dragged the C# script to another gameobject. Couldn't figure out why I kept getting 'unassigned' errors even though I properly assigned my intended GameObject. Thanks again.

Apr 19 '12 at 12:24 AM NorthernEagle
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3071
x1134
x692
x123
x87

asked: Aug 28 '11 at 05:09 PM

Seen: 4635 times

Last Updated: Aug 25 '12 at 03:00 PM