- Home /
Unable to use parameter in javascript.
Hi, I'm trying to make a script that send values from a javascript script to a C# script.
My problem is that I can't get the functions that send the info to accept a parameter.
Here is my script.
#pragma strict
import System.Collections.Generic;
public var csScript : TankController;
function Start () {
csScript = this.GetComponent("TankController");
AddVector();
}
public function AddVector (vctStr : String) {
csScript.SendMessage ("AddVectorPoint",vctStr);
}
When I try to run the game I get this error:
Assets/Scripts/ParseMessage.js(12,18): BCE0017: The best overload for the method 'ParseMessage.AddVector(String)' is not compatible with the argument list '()'.
Thanks for your help.
Answer by TanselAltinel · May 08, 2018 at 11:59 AM
Hi,
First and foremost, Unityscript (what you refer as Javascript) will be discontinued. So I strongly advise you to switch to C#.
In Unity C# and UnityScript are being compiled by different compilers and UnityScript is compiled before C#, so while UnityScript can access to C# scripts, C# scripts cannot reach UnityScript scripts.
If you still want it to work, here's a workaround in another answer:
https://answers.unity.com/questions/252865/accessing-a-c-field-from-javascript.html
Getting back to your question, you should provide your other script for us to provide a solution, however it looks like you are trying to pass another type to your method aside from String, which only accepts String. You should check your input types for your methods.
Your answer
![](https://koobas.hobune.stream/wayback/20220612161140im_/https://answers.unity.com/themes/thub/images/avi.jpg)