x


Array/ List not showing up in the inspector

I am trying to create an array to hold something but it is not appearing in the inspector so I cannot populate it, I could do it with code but for a reason that is unknown to me I cannot simply drag the things I want to populate the array with into it from the hierarchy like I usually can

 var menuItems:MenuItem[];

anything wrong with that that would cause it to not show up in the inspector? MenuItem is the class I want to populate my array with

more ▼

asked Feb 21, 2011 at 04:13 AM

wat gravatar image

wat
1 1 2 2

MenuItem is a custom Attribute-class for editor scripts. I guess that was the problem. http://unity3d.com/support/documentation/ScriptReference/MenuItem.html

Feb 21, 2011 at 04:26 AM Bunny83
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Nevermind It turns out my prefab for my menu items was named the same as the script and unity apparently hates that.. I had to change the name of my script to lower case letters and then change that line to use

  var MenuItems:menuItem[];
more ▼

answered Feb 21, 2011 at 04:17 AM

wat gravatar image

wat
1 1 2 2

Don't name a variable in PascalCase or a class in camelCase. Pick a name that hasn't already been used. Having a variable be the same name as a class is not good practice. If you want to be able to access an object like an array, you can use indexers, though. http://msdn.microsoft.com/en-us/library/2549tw02.aspx (There is no way to work with these in UnityScript, as far as I know.) Unity's Vector2/3/4 and Color, for example, use indexers.

Feb 21, 2011 at 12:16 PM Jessy
(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:

x2055
x749
x1

asked: Feb 21, 2011 at 04:13 AM

Seen: 3596 times

Last Updated: Feb 21, 2011 at 04:13 AM