using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// Отображение разсеров объекта
/// как в чертежах
/// </summary>
public class Size : MonoBehaviour
{
    GameObject LineX;
    GameObject LineZ;
    float sizeX;
    float sizeZ;


    // Start is called before the first frame update
    void Start()
    {
        sizeX = transform.position.x;
        sizeZ = transform.position.z;
    }

    // Update is called once per frame
    void Update()
    {
        if (sizeX != transform.position.x || sizeZ != transform.position.z) {
            sizeX = transform.position.x;
            sizeZ = transform.position.z;
            Destroy(LineX);
            Destroy(LineZ);
            CreateSize();
        }        
    }

    public void CreateSize()
    {
        var size = transform.localScale;
        LineX = Grid.NewLine(new Vector3(0, 0, -0.5f), new Vector3(0, 0, -0.5f), new Vector3(size.x*10, 0, -0.5f), "SizeX", 0.1f).gameObject;
        LineZ=Grid.NewLine(new Vector3(-0.5f, 0, 0), new Vector3(-0.5f, 0, 0), new Vector3(-0.5f, 0, size.z*10), "SizeZ", 0.1f).gameObject;
    }
}
