diff --git a/Runtime/Type/Enum/Orientation.cs b/Runtime/Type/Enum/Orientation.cs index e5ad21e..46b43ce 100644 --- a/Runtime/Type/Enum/Orientation.cs +++ b/Runtime/Type/Enum/Orientation.cs @@ -6,7 +6,7 @@ using UnityEngine; namespace XericLibrary.Runtime.Type { /// - /// ʸ����λ + /// 三维方向指示 /// public enum Vector3Orientation { @@ -18,7 +18,7 @@ namespace XericLibrary.Runtime.Type Right, } /// - /// ʸ����λ + /// 二维方向指示 /// public enum Vector2Orientation { @@ -27,4 +27,33 @@ namespace XericLibrary.Runtime.Type Left, Right, } + public static class OrientationExtend + { + public static Vector3 GetVector(this Vector3Orientation orient) + { + return orient switch + { + Vector3Orientation.Front => Vector3.forward, + Vector3Orientation.Back => Vector3.back, + Vector3Orientation.Up => Vector3.up, + Vector3Orientation.Down => Vector3.down, + Vector3Orientation.Left => Vector3.left, + Vector3Orientation.Right => Vector3.right, + _=> Vector3.zero, + }; + } + + public static Vector2 GetVector(this Vector2Orientation orient) + { + return orient switch + { + Vector2Orientation.UpFront => Vector2.up, + Vector2Orientation.DownBack => Vector2.down, + Vector2Orientation.Left => Vector2.left, + Vector2Orientation.Right => Vector2.right, + _=> Vector2.zero, + }; + } + } + }