- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
CurlyFries · Nov 07, 2012 at 08:26 PM ·
javascripttextguitextbce0022
BCE0022 Cannot convert 'function(): String' to 'String'.
Hello. I am new to Unity, so sorry if I am asking an obvious question. I am getting an error when running this code:
function Update () {
var camPosY = Camera.main.transform.position.y;
guiText.text = camPosY.ToString;
}
I get this error: Assets/Display.js(9,32): BCE0022: Cannot convert 'function(): String' to 'String'.
Please help :)
Thanks in advance :D
Comment
Best Answer
Answer by daterre · Nov 07, 2012 at 08:54 PM
Change this
guiText.text = camPosY.ToString;
to this
guiText.text = camPosY.ToString();
Note the parentheses indicate a function call.
Answer by Demigiant · Nov 07, 2012 at 08:48 PM
You forgot the parenthesis ;)
guiText.text = camPosY.ToString();
(the error was telling you that you were trying to assign a function to a string value)
Your answer
Follow this Question
Related Questions
changing font + size of text 1 Answer
How do I change the text of a gui image text 1 Answer
How to display text using javascript ? 1 Answer
Create GUIText from Javascript 3 Answers