私が持っている場合:
class Test
{
private Vector2 v;
public Vector2 Velocity
{
get { return v; }
set { v = value; }
}
}
その後:
Test t = new Test();
t.Velocity = new Vector2(2, 2);
t.Velocity.Normalize();
Console.WriteLine(t.Velocity); // here not normalized
Vector2 tmp = t.Velocity;
tmp.Normalize();
t.Velocity = tmp;
Console.WriteLine(t.Velocity); // here normalized
Console.Read();
プロパティVelocityでNormalizeを直接呼び出そうとすると、正規化されず、tmp Vector2では正規化されるのはなぜですか?
PSVector2は構造体です:
public struct Vector2 : IEquatable<Vector2>
{
public float X;
public float Y;
...
public void Normalize() {...}
}