Script-centric tutorials?

Hi, just got a Mac Mini for trying Unity before the Win release. I’ve been looking through tutorials, but all that I’ve found so far is very focused on the GUI.

Are there any documents that describe the process when generating everything through code? E.g. where is the entry point, how do I create meshes, texture them etc?

Thanks!

Looked around some more, still can’t find anything. Maybe there’s something in the video tutorials, but the overzealous firewall keeps me from accessing them.

Can anyone tell me how to do the simplest possible “Hello World”? No cameras, no lights, no nothing except a script that writes to the console upon starting the application?

Thanks.

Hi Jonas,

I don’t think there are any video tutorials on Scripting in Unity. I had the same problem you’re having now when I first started using Unity. What really helped was looking at the code in the 3D platformer tutorial project files and also searching through the Unity Documentation - Scripting Reference.

To answer your question about writing to the Console when you start the game, here’s one way you could do it.
-Create an Empty GameObject. This will hold the Script component that’s going to contain the code that’ll write to the console. Scripts aren’t standalone, for the most part they need to be attached to GameObjects.

-Now create a JS or C# script (I don’t know any Boo, sorry). Open up the script. It will most likely already have a Start or Awake function. I believe the Awake function gets called when the Script Component is initialized, which is done automatically when the game starts.

-In the Awake function, type in

Debug.Log("your string goes here");

Now when you run the game, it should print your string to the console.

I hope this helps.
-Yilmaz

Great, thanks, that got me started!

(Debug.Log and the empty GameObject were the missing parts. Note for others: you also need to drag the BehaviorScript on to the GameObject, and “Awake” was called “Start” for me)

Glad to hear it worked.

Just to clarify, Start() and Awake() are seperate functions. If you used C#, Start() might be the one that appears by default but Awake() is still available to you. Just add it like this:

C#

public void Awake() {
   //code goes here
}

Javascript

function Awake() {
   //code goes here
}

Awake always gets called before Start so it comes in handy from time to time.
-Yilmaz

Cool, thanks.
Strange though: why is there no “override” keyword for the C# method?
Is it called by reflection? That would be a less-than optimal design, performance-wise, when there are lots and lots of objects that are called often.

Or is there a Unity pre-processor that automatically fills in stuff like that to simplify the code?

I think in my setup, I’ll probably have a single script, which loads and calls my external DLL, so I won’t be hurt by reflection issues. I’m just curious how the system is designed.