Awake gets ignored

I have a script called GoalOne.
If the game starts, the Awake-section of the script gets skiped or ignored.

I have no idea…

the script:

var alive = true;
var current = 0;
var MainCamera:Transform;
var Spawn:Transform;

Spawn.particleEmitter.active=false;

MainCamera.transform.position.x=32*PlayerPrefs.GetInt("current")-16;

Position();

this is the part of the script from pragma-strickt to the first function.
Everything else works fine. What is wrong?

Thanks for your attention : )

There is no “Awake section”. Each script represents a class. Everything outside of a function belongs to the class ans should only contain member variable declarations.

The Unityscript compiler (or to be more precise the boo compiler which is used for UnityScript) puts all code that isn’t within a function into a function called “Main”. This is just a dummy function which get never called. You should put all code you want to be executed at start either in the Awake or Start function.

// UnityScript
var alive = true;
var current = 0;
var MainCamera:Transform;
var Spawn:Transform;

function Awake()
{
    Spawn.particleEmitter.active=false;
    MainCamera.transform.position.x = 32*PlayerPrefs.GetInt("current")-16;
    Position();
}