diff options
Diffstat (limited to 'AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs')
-rw-r--r-- | AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs b/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs deleted file mode 100644 index 4cc13d1..0000000 --- a/AlienSurvival/Assets/Test/Scripts/TestFakeHeight.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -#if UNITY_EDITOR -using UnityEditor; -#endif - -//[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; - } - } - [SerializeField] private float m_Height; // current fake height - - public float x - { - get - { - return transform.position.x; - } - - set - { - Vector3 pos = transform.position; - pos.x = value; - transform.position = pos; - } - } - - public float y - { - get - { - return transform.position.y - m_Height; - } - set - { - Vector3 pos = transform.position; - pos.y = value + m_Height; - transform.position = pos; - } - } - - public Vector3 position - { - get - { - Vector3 pos = new Vector3(x, y, height); - return pos; - } - set - { - height = value.z; // height先设置 - x = value.x; - y = value.y; - } - } - - public Vector2 positionOnGround - { - get - { - Vector2 pos = new Vector2(x, y); - return pos; - } - set - { - x = value.x; - y = value.y; - } - } - - private SpriteRenderer m_SpriteRenderer; - - private void OnEnable() - { - m_SpriteRenderer = GetComponent<SpriteRenderer>(); - } - - private void Start() - { - Project(); - } - - void Project() - { - Vector3 pos = transform.position; - pos.y = y + height; - transform.position = pos; - - if (m_Shadow != null) - { - m_Shadow.position = new Vector3(transform.position.x, transform.position.y - m_Height, transform.position.z); - } - - // 根据y设置sortOrder - m_SpriteRenderer.sortingOrder = (int)(-y * 100); - } - - void Update() - { - Project(); - } - -#if UNITY_EDITOR - - private void OnDrawGizmos() - { - // dash line - Vector3 start = transform.position; - Vector3 end = start - new Vector3(0, m_Height, 0); - - Handles.DrawDottedLine(start, end, 1f); - Handles.DrawWireCube(end, new Vector3(0.1f, 0.1f, 0f)); - - } - -#endif - -} |