Project Scripting - Tracking variables (General Question)

I'm a total newbie at scripting (and programming in general), am having no problems with the logical or procedural aspects of learning Javascript but am finding it extremely frustrating keeping track of which variables have been declared for which Object so I can call them from elsewhere.

Could some experienced programmer please point me in the right direction.

  • Is there an editor out there that will summarise the variables on a separate document?

Thank you in advance RobF

I'd recommend dropping JavaScript, picking up C# and using Visual Studio. That gives you very nice Intellisense - so the editor knows all members (variables and methods) and when you type only the first few letters, you'll get a list to select from (or you can use a key combination to see all without even typing anything).

In these times, you don't type your variable/method names anymore - you just pick them from the list (usually what you do is type the first few characters and then hit tab). It's much faster than using an editor like Unitron and typing everything out.

Besides, if you are completely new to programming, I'd recommend learning the basics in actual programming tutorials (not Unity tutorials) because that'll give you a much better foundation in the long run. One good Unity/C# tutorial I can recommened (which covers the basics) is:

Programming with C# and Unity

Once you have a basic understanding of programming - converting that UnityScript stuff into C# is a nice warm up practice ;-)

I think the best advice I can give to beginners is a good starting structure and a naming convention... ie, don't call a position vector 'p' when you could call it 'playerPosition'. For me, I always think about how I will see things in 9-12 months time. When you are coding today you will know what is going on but when you come back in 9 months time to add functionality or fix a bug you'll be totally stumped to what is going on without a good coding structure.

That said, this comes with experience... my early projects would look horrendous now.

I also try and cut down on global variables (but i'm not sure everone would agree with that one).

I also try and not 'overlap' any GameObject variables... ie the Player Object only contains stuff that relates to that object. I mean I wouldn't process any GUI stuff or other GameObject stuff within those scripts, I'd send any data I need to the required scripts instead of having external script getting data.

Not sure about UnityScript(Javascript) but if you went down the C# route, Visual Studio has tracking stuff for classes etc so you can track variables and where they are used... also the intellisense is a great help (plus - if you are new to programming it's probably as easy to learn c# as Javascript).