• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
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
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CurlyFries · Nov 07, 2012 at 10:20 PM 0
Share

Thank you :D.

avatar image
1

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)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image CurlyFries · Nov 07, 2012 at 10:20 PM 0
Share

Thanks :D.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What's wrong with my function? It keeps telling me 'loseText' is not a member of 'UnityEngine.GUIText'. Please help, please and thank you! 0 Answers

How to display text using javascript ? 1 Answer

Create GUIText from Javascript 3 Answers

GUIText only appearing in Unity Simlutor, but not actual iPad..why? 0 Answers

changing font + size of text 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges