How do I convert a char to char*?
Code:
DeathText.text = new String(' ');
Error CS1503 Argument 1: cannot convert from 'char' to 'char*'
I’m using Visual Studio
How do I convert a char to char*?
Code:
DeathText.text = new String(' ');
Error CS1503 Argument 1: cannot convert from 'char' to 'char*'
I’m using Visual Studio
You don’t want to use a char pointer in Unity as it requires unsafe code. The String constructor has several overloads but there is none that takes just a single char value. In almost all cases you don’t need / want to use a string constructor at all.
If you want to set the text to a string that contains a single space character you would just do
DeathText.text = " ";
Though in most cases when you want to clear the text you would assign an empty string:
DeathText.text = "";
Note that string literals use double quotes "
while char literals use single quotes '
.
This does not look like Unity, but try:
DeathText.text = new string(’ ');
string with small s.