📜  带有 switch 语句的 vector2 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:42.239000             🧑  作者: Mango

代码示例1
//this goes where you're declaring variables
public Vector2 foo = Vector2.zero;

//this is what the switch statement would look like
switch (foo)
{
    case Vector2 v when v.Equals(Vector2.up):
        Debug.Log("Up");
        break;
    case Vector2 v when v.Equals(Vector2.left):
        Debug.Log("Left");
        break;
    case Vector2 v when v.Equals(Vector2.back):
        Debug.Log("Back");
        break;
}