- Home /
GetComponent Error
Hi... I'll get this error : BCE0023: No appropriate version of 'UnityEngine.GameObject.GetComponent' for the argument list '(function(): void)' was found. What's problem in my Java Script file?
Please post your code so we can track down the exact problem. Telling from the error, 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
You can use GetComponent to cache a copy of the script you are trying to access:
var other : ScriptName = gameObject.GetComponent(ScriptName);
then access the function by doing other.DoWorkFromScript();
Answer by seth_slax · Mar 03, 2015 at 12:33 AM
I just ran into this same error. Turns out it was because the script I was attempting to access from another GameObject had the same name as a function/void I had in the script I was trying to access it from.