Basic concepts

From Unify Community Wiki
Jump to: navigation, search

Contents

Basic Concepts

Script Execution

Unity's Javascript is subclassed from Monobehaviour, and these classes have special functions which will be called by the engine. These scripts will only be called if they've been attached as a component of a game object. If a class does not subclass from Monobehaviour then it must be called by another script which is a subclass of Monobehaviour.

Script Termination

Scripts which are derived from Monobehaviour can be terminated by destroying either the component or the game object which the component is attached to. After the object is destroyed the garbage collector is free to delete that script.

Declarations

Declarations define the elements of the script. Type declarations are used to define classes and enums.
A declaration defines a name in the declaration space to which the declaration belongs. Except for overloaded members, it is a compile-time error to have two or more declarations that introduce members with the same name in a declaration space. It is never possible for a declaration space to contain different kinds of members with the same name. For example, a declaration space cannot contain a field and a method by the same name.
There are different types of declaration spaces:
-Each class creates a new a new declarations space. Names are introduced into this declaration space through class-member-declarations. A class permits the declaration of overloaded methods. Base classes do not contribute to the declaration space of a class, therefore a derived class is allowed to declare a member with the same name as an inherited member. This hides the inherited member.
-Each enumeration declaration creates a new declaration space. Names are introduced into this declaration space through enum-member-declarations.
-Methods create a new declaration space for local variables. Names are introduced into this space through local-variable-declarations.
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Tools