summaryrefslogtreecommitdiff
path: root/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
diff options
context:
space:
mode:
Diffstat (limited to 'AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs')
-rw-r--r--AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs29
1 files changed, 20 insertions, 9 deletions
diff --git a/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs b/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
index e427e20..4cc13d1 100644
--- a/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
+++ b/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs
@@ -5,12 +5,23 @@ using UnityEngine;
using UnityEditor;
#endif
-[ExecuteInEditMode]
+//[ExecuteInEditMode]
public class TestFakeHeight : MonoBehaviour
{
[SerializeField] private Transform m_Shadow;
+ [SerializeField] private Vector3 m_Coord;
- public float height { get { return m_Height; } set { m_Height = value; } }
+
+ public float height {
+ get
+ {
+ return m_Height;
+ }
+ set
+ {
+ m_Height = value;
+ }
+ }
[SerializeField] private float m_Height; // current fake height
public float x
@@ -49,6 +60,12 @@ public class TestFakeHeight : MonoBehaviour
Vector3 pos = new Vector3(x, y, height);
return pos;
}
+ set
+ {
+ height = value.z; // height先设置
+ x = value.x;
+ y = value.y;
+ }
}
public Vector2 positionOnGround
@@ -65,8 +82,6 @@ public class TestFakeHeight : MonoBehaviour
}
}
- private float m_PreHeight;
-
private SpriteRenderer m_SpriteRenderer;
private void OnEnable()
@@ -76,15 +91,13 @@ public class TestFakeHeight : MonoBehaviour
private void Start()
{
- m_PreHeight = 0;
Project();
}
void Project()
{
Vector3 pos = transform.position;
-
- pos.y = pos.y - m_PreHeight + m_Height;
+ pos.y = y + height;
transform.position = pos;
if (m_Shadow != null)
@@ -92,8 +105,6 @@ public class TestFakeHeight : MonoBehaviour
m_Shadow.position = new Vector3(transform.position.x, transform.position.y - m_Height, transform.position.z);
}
- m_PreHeight = m_Height;
-
// 根据y设置sortOrder
m_SpriteRenderer.sortingOrder = (int)(-y * 100);
}