summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/Scripts/Physics/AABBShape.cs
diff options
context:
space:
mode:
Diffstat (limited to 'SurvivalTest/Assets/Scripts/Physics/AABBShape.cs')
-rw-r--r--SurvivalTest/Assets/Scripts/Physics/AABBShape.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/SurvivalTest/Assets/Scripts/Physics/AABBShape.cs b/SurvivalTest/Assets/Scripts/Physics/AABBShape.cs
new file mode 100644
index 0000000..abff597
--- /dev/null
+++ b/SurvivalTest/Assets/Scripts/Physics/AABBShape.cs
@@ -0,0 +1,45 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+#if UNITY_EDITOR
+using UnityEditor;
+#endif
+
+[RequireComponent(typeof(TopDownTransform))]
+public class AABBShape : ShapeBase
+{
+
+ [Tooltip("中心点(相对此节点的偏移)")]
+ [SerializeField] private Vector2 m_Centre;
+ public Vector2 centre { get { return m_Centre;} set { m_Centre = value; } }
+
+ [Tooltip("大小(TopDown空间下)")]
+ [SerializeField] private Vector2 m_Size;
+ public Vector2 size { get { return m_Size; } set { m_Size = value; } }
+
+ private TopDownTransform m_TopDownTransform;
+ private TopDownTransform topdownTransform
+ {
+ get
+ {
+ if(m_TopDownTransform == null)
+ {
+ m_TopDownTransform = GetComponent<TopDownTransform>();
+ }
+
+ return m_TopDownTransform;
+ }
+ }
+
+#if UNITY_EDITOR
+
+ private void OnDrawGizmos()
+ {
+ Vector3 pos = topdownTransform.GetProjectedPosition();
+ Handles.color = Color.green;
+ Handles.DrawWireCube(pos + new Vector3(m_Centre.x, m_Centre.y, 0), new Vector3(size.x, size.y, 0));
+ }
+
+#endif
+
+} \ No newline at end of file