Typecasting as in from Object to GameObject, int to float etc.
Answer by Eric5h5
Jul 05, 2012 at 05:37 PM
You can use "as" for reference types.
var foo : Object;
var bar = foo as GameObject;
There isn't a direct method for value types, but you can use parseFloat or parseInt in the case of floats and ints.
I agree that this is not an ideal situation.
I am sorry if i haven't made myself clear to others.
Answer by nventimiglia
Jul 05, 2012 at 05:36 PM
float myHealth = 10f;
int healthA = myHealth as int;
int healthB = (int)myHealth;
Bizarrely, the question specifically asks for UnityScript and people post C# answers...not helpful....
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users post good questions and use the site effectively we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
11 People are following this question.
Error with Kimmons dialogue system/ Interface must be public or explicit
Data types and explictly stating
Debugging during runtime
Migrating data from C# to UnityScript
change button texture from different button press