You've successfully subscribed to Hacking with Unity - Learn how to create your own games
Great! Next, complete checkout for full access to Hacking with Unity - Learn how to create your own games
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

How to define a variable in Unity using C#

How to define a variable in Unity using C#

Ben Liu
Ben Liu

In C#, all are categorized into the following types:

  • Value types
  • Reference types
  • Pointer types
// basic values in Unity
int lives = 3;
float health = 100.0f;    // 100.0 will be treated as a double by default.
double heath = 100.0;
string playerName = "solider";


// reference type
GameObject go = new GameObject();


// pointers
Vector3* oldNew;
Vector3* curr;

Ben Liu

Please feel free to contact me if you have any question. <br> https://t.me/NeedoneApp