I’m trying to save alot of integers into a string, this time in javascript (unityscript). This was a fairly easy thing to do with C# and the ability to cast variable types:
class Example : MonoBehaviour{
int id = 5;
string id_list;
void Awake(){
id_list += (char)id;
Debug.Log(id_list);
}
}
That returns . How do I go about returning in unityscript?
If you want to cast an int to char, then you can use
var c : char = id;
or
var c : char = System.Convert.ToChar(id);
Please note, that this will not show in console (and I believe in GUI too). Instead, if you want to display clubs character, use its Unicode character. In C# you would assign it as:
var c = '\u2663';
while in UnityScript use:
var c : char = System.Convert.ToChar(0x2663); // 0x because it's hexadecimal
Small edit: of course var c : char = 0x2663; should work as well…