本文主要是介绍C# struct and Unity3d Vector3,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
The new
operator is also used to invoke the constructor for value types. Value-type objects such as structs are created on the stack.
—— C# new operator
This is not like Java. In C#, you can new a struct fearlessly. It's not terribly wasteful because it's created on the stack, not the heap.
Feel free to use new
in C# !
Unity3d: Vector3 Transform.position is a property and Vector3 is a struct type. So the get property returns a copy of Vector3.
这篇关于C# struct and Unity3d Vector3的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!