- Home /
int to string, weird string value?
MainScript.js
var CorrectOrder: String;
var ClickedOrder: String;
function ClickedTube(ID: int)
{
ClickedOrder = ClickedOrder + ID.ToString;
print(ID.ToString);
}
OtherScript.js
var myID: int;
var MainObject: MainScript;
function Awake()
{
MainObject = transform.parent.GetComponent(MainScript);
}
function OnMouseDown()
{
MainObject.ClickedTube(myID);
}
What I'm trying here is basically letting the player click on a couple of "items", which then should send an ID number to the main script. the ClickedTube function adds it to a string.
However it seems like it does not send the actual number, or the conversion to string is wrong, as it gives me the following instead of an int value:
CompilerGenerated.__MainScript_ClickedTube$callable0$10_42__
and prints the following:
CompilerGenerated.__MainScript_ClickedTube$callable0$10_42__
UnityEngine.MonoBehaviour:print(Object)
MainScript:ClickedTube(Int32) (at Assets/Standard Assets/Scripts/PanFluteStatue/MainScript.js:11)
FluteScript:OnMouseDown() (at Assets/Standard Assets/Scripts/PanFluteStatue/FluteScript.js:10)
UnityEngine.SendMouseEvents:DoSendMouseEvents()
I wonder, what am I doing wrong?o.o
Thanks in advance!
Answer by BiG · Feb 17, 2012 at 10:17 AM
As a start, ToString is a function, so you should write:
ClickedOrder = ClickedOrder + ID.ToString();
, but maybe that's all you have to change.
Your answer
Follow this Question
Related Questions
Convert Array to String 3 Answers
Convert Text to float 3 Answers
parseInt givin' me issues! 2 Answers
Why Won't This Work? 1 Answer
Convert int to string and back again 2 Answers