- Home /
how to make easily accessible classes. the type like Unity has in JS for example.
What I'm thinking about is, for example being able to access Mathf.Clamp() or Mathf.Slerp() so easily as just putting the name of the class and then function or variable, in any script in the game.
How to write a file like this so it works the same way? thank you in advance
Comment
Best Answer
Answer by Eric5h5 · Sep 24, 2010 at 01:14 AM
Use a static function:
static function Add (a : int, b : int) : int {
return a + b;
}
If you saved that in a script called MyMath, then you could do
print ( MyMath.Add(1, 2) );
Your answer
Follow this Question
Related Questions
How to list all the properties and methods from the class? 1 Answer
Probably Dumb Question: Update(), Start(), etc. Don't Work Inside Classes (JavaScript)...? 2 Answers
Is there anything wrong with using lots of static classes? 1 Answer
Singleton class always returning null 3 Answers
Creating a static array of a class 1 Answer