- Home /
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
Answer by jashan · Feb 21, 2010 at 02:48 PM
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:
Once you have a basic understanding of programming - converting that UnityScript stuff into C# is a nice warm up practice ;-)
That link you provided if very good, thanks Jashan. I've taken the advice and hence taken the leap to C#.
Answer by fallingbrickwork · Feb 20, 2010 at 11:51 PM
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).
I'm sure you're correct about the C# route, but it seems all the "full" tutorials available for Unity are Script based and the thought of adapting them to C# is rather daunting for this Newbie.
Check the www.3dbuzz.com website or the following forum thread (http://forum.unity3d.com/viewtopic.php?t=39327&highlight=3dbuzz). Their "full" project is in C# which could help you getting started.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
How to make an GUILayout.Window draggable ? 3 Answers
Script that switches between first and third person controller 3 Answers
How to edit a enumerator in the editor? 2 Answers
How do I reference variables from one editor script in another 0 Answers