|
I've read that we should avoid allocating memory at runtime. Does this apply to every type of variable? I know that I shouldn't use new to initialize reference class object at runtime. But what's about struct like Vector2 or Vector3? Should I avoid to create (using new) them at runtime too?
(comments are locked)
|
|
anytime you want to set any component of a transform you have to call new Vector3, directly in c sharp and under the hood in javascript. to quote trinity from the matrix, "Dodge this!" What I don't understand is that Vector3 is a value type. Its properties are float. What's so much different between create new Vector3 and create three new float variables?
Mar 27 '11 at 10:48 AM
jjobby
there isn't too much difference. under the hood, floats are structs in .net. my point is that you can't avoid new Vector3 at runtime, so why worry? what kinds of trouble are you running into that causes you to ask your question? There are many knowledgeable people in the community that can quickly answer a very specific question.
Mar 27 '11 at 11:52 AM
loopyllama
So, you basically mean that I shouldn't worry about it right? I also use new Vector3 but the use of new keyword makes me curious if it's appropriate or not. Because I've read that it's a bad thing to frequency create new object at runtime. Thanks for the answer. :)
Mar 27 '11 at 08:32 PM
jjobby
(comments are locked)
|
