In Unity I am using the Javascript syntax for pretty much everything. Outside of that, I am importing several items from the .Net library:
import System;
import System.Net;
import System.Net.Sockets;
import System.Text;
import System.Runtime.Serialization.Formatters.Binary;
import System.Xml;
In conjunction with this I am doing some string manipulation and cannot access some simple methods such as length, charAt etc. and I believe it is due to the System.Text .Net library and String being a member of that.
My reasoning for this is because I had to use .Net String calls in order to do what I needed.
To me, this seems like a bug… Thoughts?
Regards,
– Clint
That method and property do not exist in the string class…
you want myString.Length and then to just use array syntax. myString[index]
So yeah, you want to use the .NET stuff. I don’t see it as a bug. (Could/probably have the wrong perspective or missing details, as usual.
)
cheers,
-Jon
Well the part that just seems weird… Is I am using Javascript and my declaration for the string was super simple:
var contentStr = "";
And I was fully expecting to be able to use Javascript string manipulation on it but because I had imported the .Net System.Text library it basically overrode all the Javascript String data type for that script.
My thought is I should have to instantiate/specify a .Net String type to use those instead of all strings fall under that.
Not sure if I am making sense. Thoughts?
Thanks,
– Clint
Okay, so I got some more information and maybe this is what aarku was talking about and I misunderstood.
The Javascript implementation that is currently in Unity does not support the String class. So all string methods and properties are of the .Net syntax.
Not sure on the future plans and if eventually those will get wrapped in our not.
Thanks for all the help!
– Clint
This is true. The String class is the .Net System.String class no matter which language you use in Unity. Version 1.2 added a Javscript-compatible Array class, but the String class has not been wrapped yet.