Hello i am trying to link / call 1 javascript file with another javascript file.
The code is as follows:
using UnityEngine;
using System.Collections;
public class mycarscript : MonoBehaviour {
public static JDisplaySpeed Speedo;
//public static JCar care; // car to get speed and distance from
//public float factor = 1.2f; // angle of speed-hand is km/h * factor
}
function OnGUI () {
GUI.Label (Rect (25, 25, 100, 30), “Total Time: \n”+ Mathf.Floor(Time.time )+" Secs");//realtimeSinceStartup));
GUI.Label (Rect (25, 50, 500, 30), “Distance Travelled: \n”);
GUI.Label (Rect (25, 75, 100, 30), “Speed: \n”+ Speedo.dist);
GUI.Label (Rect (25, 100, 100, 30), "Max Speed: ");
GUI.Label (Rect (25, 125, 100, 30), "RPM: ");
GUI.Label (Rect (25, 150, 100, 30), "Gears: ");
}
}
mycarscript is 1 javascript file and JdisplaySpeed another javascript file.
i want to access a variable in JdisplaySpeed which is ‘dist’ and get its value in mycarscript javascript file. i have applied this code to my main camera.
basically i want to display this 'dist variable’s value in my GUI.
‘mycarscript’ file is my GUI coded file name
Error Msg: Assets/Scripts/mycarscript.js(7,1): BCE0043: Unexpected token: public.
How can this be acheived.
How can this be done i get an unexpected token error.