Size.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. /// <summary>
  5. /// Отображение разсеров объекта
  6. /// как в чертежах
  7. /// </summary>
  8. public class Size : MonoBehaviour
  9. {
  10. GameObject LineX;
  11. GameObject LineZ;
  12. float sizeX;
  13. float sizeZ;
  14. // Start is called before the first frame update
  15. void Start()
  16. {
  17. sizeX = transform.position.x;
  18. sizeZ = transform.position.z;
  19. }
  20. // Update is called once per frame
  21. void Update()
  22. {
  23. if (sizeX != transform.position.x || sizeZ != transform.position.z) {
  24. sizeX = transform.position.x;
  25. sizeZ = transform.position.z;
  26. Destroy(LineX);
  27. Destroy(LineZ);
  28. CreateSize();
  29. }
  30. }
  31. public void CreateSize()
  32. {
  33. var size = transform.localScale;
  34. 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;
  35. 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;
  36. }
  37. }