You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Class used to write extension methodes in
/// </summary>
public static class ExtensionMethods
{
/// <summary>
/// Converts provided Direction to Global Vector3
/// </summary>
/// <param name="direction">Direction to convert</param>
/// <returns>Global Vector3 direction</returns>
public static Vector3 ToVector(this Direction direction)
{
switch (direction)
{
case Direction.Forward:
return Vector3.forward;
case Direction.Right:
return Vector3.right;
case Direction.Back:
return Vector3.back;
case Direction.Left:
return Vector3.left;
default:
return Vector3.zero;
}
}
/// <summary>
/// Converts provided Direction to local Vector3
/// </summary>
/// <param name="direction">Direction to convert</param>
/// <param name="transform">Transform to use as directions local space</param>
/// <returns>Local Vector3 direction</returns>
public static Vector3 ToVector(this Direction direction, Transform transform)
{
switch (direction)
{
case Direction.Forward:
return transform.forward;
case Direction.Right:
return transform.right;
case Direction.Back:
return -transform.forward;
case Direction.Left:
return -transform.right;
default:
return Vector3.zero;
}
}
}