I am learning unity using tutorials. I learned the #pragma strict when using GetComponent generates this error:
Assets/scriptObjA.js(12,69): BCE0019: ‘foundVar’ is not a member of ‘UnityEngine.Component’.
MonoDevelop-unity adds the #pragma strict to my java script as default. is not used in the tutorials, is it a good practice to use it?
When I remove #pragma strict from the script, the code works correctly. Should I be concerned?
Is there a better technique to create/access global variable/functions?
I have parsed the code down from the tutorials down to this example:
The error is generated accessing a variable found in a script that is a component of a prefabsceneManager from an object called prefabObjA. Here are the two scripts:
scriptSceneManager.js
var foundVar : float = 20;
function Start () {
}
function Update () {
}
function FoundMe () {
}
scriptObjA.js
var varK : int = 3;
var lookFor : GameObject;
function Start () {
}
function Update () {
print( lookFor.transform.GetComponent("scriptSceneManager").name );
print( lookFor.transform.GetComponent("scriptSceneManager").foundVar );
}
I am assigning the variable lookFor in the interface with the prefabSceneManager that has scriptSceneManager.js as a component.
Thanks in advance for your help/advice.