- Home /
Add multiple ints to a string line.
So heres the code i was trying to do.
Notifier.GetComponent <Text>().text = ("Saved " + (minersDone.ToString) + " / " + (minersTotal.ToString) + " Villagers");
that didnt work out too well, but i figure it would be an easy fix.
it gave me this error message.
Assets/QuestHandler.cs(156,63): error CS0019: Operator +' cannot be applied to operands of type
string' and `method group'
if someone knows the quick fix please let me know, im sure its really simple; at least i hope it is.
Thank you for your time!
Answer by Aeleck · May 15, 2015 at 07:05 AM
I get stuck with that error all the time because I always forget one thing with ToString
. It's a method which means it needs to be ToString()
.
Notifier.GetComponent <Text>().text = ("Saved " + (minersDone.ToString()) + " / " + (minersTotal.ToString()) + " Villagers");
Should do the trick for ya. Good luck :)
Answer by Cherno · May 15, 2015 at 01:29 AM
First of all, using ToString() in this case shouldn't be needed, Unity does that automatically. Furthermore, try using ToString() instead of ToString.
Your answer
![](https://koobas.hobune.stream/wayback/20220613195624im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Referencing to an initiated Text 1 Answer
Multiple Text of canvas with One script ?? 1 Answer
Displaying variable on UI text every frame (JS) 1 Answer
Problems to change text from a child in a child 1 Answer
Score text wont appear 1 Answer