Calling method of a class

I’m confused why this is not working. I’ve created a bare bones class with a function called Print()

public class Test {

    public function Print() {
        print ('testing');
    }

}

And trying to create an instance of the object and call the Print function in it.

#pragma strict

function Start () {
    var testClass = new Test();
    testClass.Print();
}

function Update () {

}

Why does ‘testing’ not get printed to the console?

If you want to print something to the debug console of the Editor you have to use Debug.Log

Check also http://docs.unity3d.com/Documentation/ScriptReference/Debug.html for more infos

I got it to work by omitting the first line and the last in the Test class, ie don’t define a class, just the method in a file called Test.js. There was a warning message though, but the word Testing was printed.

Ah excellent, thanks guys!