From 5c4faf1522aab5348fba6dff93013a3ff68ddaef Mon Sep 17 00:00:00 2001 From: LiRuoChen <571244399@qq.com> Date: Tue, 28 Nov 2023 11:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=BD=E7=84=B6=E7=BB=8F=E5=8E=86=E4=BA=86?= =?UTF-8?q?=E5=9B=BA=E6=80=81=E7=A1=AC=E7=9B=98=E6=8D=9F=E5=9D=8F=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E5=A5=BD=E5=9C=A8git=E7=BB=99=E5=8A=9B=EF=BC=8C?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E7=9A=84=E6=96=87=E4=BB=B6=E4=B8=8D=E5=A4=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/Type/Enum/Orientation.cs | 33 ++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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, + }; + } + } + }