Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class EntityBase : MonoBehaviour
- {
- // Entity data
- private string EntityName;
- private Vector2 EntityPosition;
- private int EntityZIndex;
- private float EntityRotation;
- private EntityType EntityType;
- private EntityCategory EntityCategory;
- // Debug data
- public Color gizmoColor = Color.red;
- private DebugManager debugger;
- private Vector3 position;
- private string labelText;
- private void Start()
- {
- debugger = FindObjectOfType<DebugManager>();
- position = transform.position;
- labelText = "(" + Mathf.Round(position.x) + ", " + Mathf.Round(position.y) + ")";
- }
- private void Update()
- {
- if (position != transform.position)
- {
- position = transform.position;
- labelText = "(" + Mathf.Round(position.x) + ", " + Mathf.Round(position.y) + ")";
- }
- }
- private void OnDrawGizmos()
- {
- Gizmos.color = gizmoColor;
- // Calculate the center, draw cube
- Vector3 tileCenter = new Vector3(Mathf.Round(position.x), Mathf.Round(position.y), 0f);
- Gizmos.DrawWireCube(tileCenter, Vector3.one * 1f);
- // Draw a label gizmo above the wire cube with the cached label text
- GUIStyle style = new GUIStyle();
- style.normal.textColor = gizmoColor;
- style.alignment = TextAnchor.MiddleCenter;
- Handles.Label(tileCenter + Vector3.up * 0.6f, labelText, style);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement