Changing Struct properties by value VS by reference

Structures are passed by value in C#, so you cannot change the x or y value of a Vector3 and you need to create a new Vector3 and assign it to the Vector3 that you want. However, in JavaScript, you can write it as follows.

JavaScript:

transform.position.x = 1;

C#:

transform.position = new Vector3(1, transform.position.y, transform.position.z);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.196.172