using UnityEngine; using TMPro; public class WaterLevelController : MonoBehaviour { public TextMeshPro waterLevelText; public TextMeshPro cubeMassText; private float waterLevel = 100f; public float currentCubeVolume = 0f; public float currentCubeMass = 0f; void Update() { waterLevelText.text = "WATER VOLUME " + (waterLevel + currentCubeVolume).ToString().Replace(",", ".") + "L"; cubeMassText.text = "OBJECT MASS " + currentCubeMass.ToString().Replace(",", ".") + "KG"; } private void OnTriggerEnter(Collider other) { if (other.gameObject.tag != "DensityCube") return; DensityCube dc = other.GetComponent(); currentCubeVolume = dc.cubeVolume; currentCubeMass = dc.mass; } }