Controling what variables show up in the inspector and how?

Hello,
How do I control what global variables in a script show up in the inspector under the script’s component, and what doesn’t show up?

I was also wondering how to organize an array in a script in such a way where in the inspector, after I set the single size of my array, I see the ‘size’ number of treed variables within the array show up, instead of having to create individual separate arrays and set each size to be the same size in the inspector.

Also, I know how to work with ‘Array’ but what if I want to set the data type of my array elements so that I can use the Add, Clear and RemoveAt functions? I know to use ‘: dataType[ ]’, but also noticed that when I do this, I can not use the Add, Clear and RemoveAt functions.

Thank you,
Michael S. Lowe

Use @HideInInspector above the variable you want to hide.

@HideInInspector
var blah = 99;

If you’re talking about multidimensional or jagged arrays, those don’t show in the inspector. You could write a custom inspector though.

Use List. http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx JS syntax is slightly different (e.g., List. in JS instead of List in C#), otherwise everything applies.

var foo : List.<int>;

The problem with that is then the variable is private, and therefore not global (not project-wide global, anyway). Public/private isn’t really about showing in the inspector or not; private variables still show in debug mode after all. Use @HideInInspector as mentioned above for hiding stuff in the inspector, regardless of public/private status.

Better to read the List docs I linked to above; there’s very little point in using Array since generics were added to JS in Unity 3. (Would be nice if the Unity docs made that more obvious.)

–Eric

Nope - do not confuse public with static. I had a client do that recently, made all his logic invalid.

Public - Everyone can see it/edit it.
Private - Only this script can see/edit it.

Static - Variable is shared for all instances of the same script. Can be public or private.

[Script technically = class IIRC].

I wasn’t referring to multi-dimensional arrays. I used a javascript one time where I set the size of an array in my inspector, and saw something like this in my inspector after setting the size to 2…

arr >
Size 2
x 0
y 0
z 0

x 0
y 0
z 0

where something like x, y and z were all properties of the same array instead of x, y and z being their own separate arrays. As opposed to ‘arr’ being a multi dimensional array (containing 2 or more elements, which wasn’t what I was trying to do), I saw that in the inspector (according to the code that was in the script), there were also arrays inside arrays (an array as a property of a different array). I think the last time I saw the perfect example of what I am trying to describe was when I used a Unity program that I downloaded a long time ago that levels a player’s feet to any given slope based on an animation provided. I set the size of the feet to 2 and then saw a whole bunch of information that I could enter for each foot, all under the same array. I was wondering how that was done.

I wasn’t referring to multi-dimensional arrays. I used a javascript one time where I set the size of an array in my inspector, and saw something like this in my inspector after setting the size to 2…

arr >
Size 2
x 0
y 0
z 0

x 0
y 0
z 0

where something like x, y and z were all properties of the same array instead of x, y and z being their own separate arrays. As opposed to ‘arr’ being a multi dimensional array (containing 2 or more elements, which wasn’t what I was trying to do), I saw that in the inspector (according to the code that was in the script), there were also arrays inside arrays (an array as a property of a different array). I think the last time I saw the perfect example of what I am trying to describe was when I used a Unity program that I downloaded a long time ago that levels a player’s feet to any given slope based on an animation provided. I set the size of the feet to 2 and then saw a whole bunch of information that I could enter for each foot, all under the same array. I was wondering how that was done.

No, then it would be static.

public static var foo = 1; // global
private static var bar = 2; // not global

Not sure what this means…the Array class is specific to JS, but since generics are supported now, there’s rarely any reason to use it. Use List instead.

Nope, not right. .NET is .NET, not related to C#. JS in Unity uses .NET (well, technically Unity uses Mono rather than .NET).

In that case I already answered: use List.

var someStuff : List.<Vector3>;

–Eric

Assets/scripts/functions/test.js(13,16): BCE0043: Unexpected token: …

Unity doesn’t recognize List.

I am using Javascript.

You need to use “import Systems.Collections.Generic;” when using generics. Also, you need to be using at least Unity 3.0.

–Eric

… but the program that was used to level a player’s feet with any given slope worked fine when it came to presenting the generic arrays in my inspector?

Presumably it didn’t use List.

var blah : Vector3[];

But you said you wanted to use Add, RemoveAt, etc.

–Eric

This will set up the inspector to keep x, y and z under the same ‘size’ variable, but how do I organize it where I won’t have to click on element(element number) in order to access x, y and z (just like how it was all done in the program that levels the player’s feet with a slope, where there was direct access to the properties without having to get past ‘element(element number)’? Can that only be done through List. and if so, how was the program that levels a player’s feet able to work on the Unity that I have since I only have Unity 2.6?

Sorry but I don’t follow that at all. Anyway, if they used List in Unity 2.6, then it would have been a C# script. Out of curiosity, any reason for using Unity 2?

–Eric

I am using whatever free version I can use right now because I can not afford any Pro versions of anything at this time ever since the time that I have been unemployed in the Computer field due to this nasty economy, due to the fact that I am either too overqualified for the job, have no work experience, or for reasons of discrimination against people with disabilities that would take me years to prove and fight in court.

Because I want to one day make an income that will make up for all the years that I have been unemployed, I really WOULD like to one day produce a product that will potentially sell to many teens (such as, “Grand Theft Soulwinning”) where teens are inspired in a game that is really all about reaching out to a hurting community with truth about a place of acceptance that no bar or club could ever bring them, informing people the same age group that it is really not a ‘church’ or a place of ‘religion’ they are getting invited to, but a place of ‘unity’, ‘relationship’ and ‘change’, while avoiding getting into trouble for soliciting and loitering in a futuristic time where the spreading of truth is not allowed and freedom of speech is stripped away. Eventually, enough group rebellion against it creates a game ending where those who were once set out to persecute you, join you. The reason I want to develop something like this is because I have lived it. Teenagers can rebel against the RIGHT things and can still have a good time doing it. It sure beats these rebellious games where teenagers are being educated at a younger and younger age to be in gangs and steal cars. This dream goal of mine all started ever since the making of, “Grand Theft Auto” years ago when I saw something disturbing about how it effected the minds of children, but I even created my own Unity interface that lets you type in scriptures in a GUI as if you are typing to a real person and tells you how accurate you are (a return value between 0.0 and 1.0), which is not something that has YET been invented in the video-gaming world. I’ve always wanted to be the lone wolf at developing my own technology step above the makers of “Grand Theft Auto” even since what I saw years ago since I have no job to afford to hire anybody to do the voices or the editing, while thinking to myself, “There has got to be a way to reach these young people before other influences do and at the same time, make it just as action-packed.” using things like rescue vehicles without having to steal anything.

If Unity is WII platform friendly, I can only imagine what something unique like this would be like played in households, but come to find, I need an expensive program such as 3D desktop to make realistic looking characters included with its visemes (mouth movements and facial expressions).

Free or paid, Unity 2 is not current. You can get a free and updated version of Unity Indy 3.x…

Jeff

Then there’s no reason for not upgrading to Unity 3. You’d be doing yourself a big favor if you started using it now.

–Eric

I downloaded the upgrade, but what happens after 30 days? About a year ago, I was nervous to even start any trial periods because I was afraid that I wouldn’t get the maximum benefits out of the 30 days because there was always something new to learn. I was also afraid that after the 30 days, the codes I write and spend valuable time on will no longer work and it would be a waste of time because I don’t plan on affording any Pro versions any time soon unless someone in the computer field hires me.

Nothing, except for the Pro features not being active anymore.

–Eric

Have a look: http://forum.unity3d.com/threads/85923-C-Optimization-Question?p=553462&viewfull=1#post553462