Answers for "vector2 with switch statement"

C#
0

vector2 with switch statement

//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;
}
Posted by: Guest on April-20-2021

C# Answers by Framework

Browse Popular Code Answers by Language