Unable to understand error message
The error message says "BCE0023: No appropriate version of 'UnityEngine.GameObject.GetComponent' for the argument list '(float)' was found." What does No appropriate version mean?
Answer by Zoogyburger · Feb 18, 2016 at 12:16 AM
Please post your script so that we can track down the problem!
I think you are trying to access a method / function using 'GetComponent' when GetComponent is used for Unity types only. Here is the component list from Unity documentation:
http://unity3d.com/support/documentation/ScriptReference/Component.html
I am attempting to access a static variable from another sprite (Scoring)
Are you trying to access a static variable from another sprite or a script on that sprite? Please post your code. Here's an example: first script:
public class script1 : $$anonymous$$onoBehaviour {
public static int number;
}
Now here is the other script that you needs to access script 1:
public class Script2 : $$anonymous$$onoBehaviour {
void Start(){
script1.number = 10;
}
}
I am coding in JS.
One end: static var score : float = 0f;
Receiving end: var inst = gameObject.Find("Instantiate"); var score = inst.GetComponent(Inst.score); Debug.Log(score);
You access a static variable in a class this way:
{class name}.{static member name}
So if this is the case:
public class firstscript: $$anonymous$$onoBehaviour {
public static bool Score = false;
}
Then you access Score from any script like this:
firstscript.Score = true;
if( firstscript.Score == true) ...
Your answer
