public static class Vector3Extensions
{
public static void SetX(ref this Vector3 v, float x) { v.Set(x, v.y, v.z); }
public static void SetY(ref this Vector3 v, float y) { v.Set(v.x, y, v.z); }
public static void SetZ(ref this Vector3 v, float z) { v.Set(v.x, v.y, z); }
public static void AddX(ref this Vector3 v, float x) { v.Set(v.x + x, v.y, v.z); }
public static void AddY(ref this Vector3 v, float y) { v.Set(v.x, v.y + y, v.z); }
public static void AddZ(ref this Vector3 v, float z) { v.Set(v.x, v.y, v.z + z); }
}
위 코드를 아무 파일에나 넣는다
사용예)
Vector3 v = new Vector3(1f, 1f, 1f);
v.SetX(3f);
Debug.Log(v); //(3f, 1f, 1f)
v.AddX(-1f);
Debug.Log(v); //(2f, 1f, 1f)
v.x = 3.f 를 쓰지 않는 이유는?
아 그거 됨? ㅅㅂ 몰랐음
나도 몰랏슴... 맨날 new로 대입했는데
사실 중국산벌꿀이었던거임...
사실 꿀도 아니고 그냥 설탕물이었던거임...
사실 그냥 물이었던거임
https://assetstore.unity.com/packages/tools/utilities/extensions-214756
완전 메이플시럽 고맙다