Hey,
here, started to play with Unity, made a little script with 2 exception blocks:
#pragma strict
private var coordinates : float[];
private var xStep : int = 1;
private var zStep : int = 1;
var x : float;
var z : float;
var movementSpeedUp : int = 1;
function Start () {
try {
x = gameObject.transform.position.x;
z = gameObject.transform.position.z;
coordinates = new float[4];
coordinates[0] = 0;
coordinates[1] = 0;
coordinates[2] = 60;
coordinates[3] = 40;
}
catch (error : System.Exception){
Debug.Log(error);
}
}
function Update () {
try {
x += xStep * movementSpeedUp * Time.deltaTime;
z += zStep * movementSpeedUp * Time.deltaTime;
gameObject.transform.position = Vector3(x, gameObject.transform.position.y, z);
if (Mathf.Abs(xStep) > 1) xStep /= 5;
if (Mathf.Abs(zStep) > 1) zStep /= 5;
if (x > coordinates[2] || x < coordinates[0]) xStep *= -5;
if (z > coordinates[3] || z < coordinates[1]) zStep *= -5;
}
catch (error : System.Exception){
Debug.Log(error);
}
}
I would like to return any error from one of those two blocks! Using Google I discovered, that I can return error of type System.Exception and it seems to be OK, because Unity does not show any errors!
What confuses me a little bit is that I can’t find definite try catch statement declaration nor in Unity API, nor through Google!
And when I write System. in MonoDevelop, Exception isn’t available option!
Could you guys, please, share your knowledge!?