28 lines
786 B
C#
28 lines
786 B
C#
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<DensityCube>();
|
|
currentCubeVolume = dc.cubeVolume;
|
|
currentCubeMass = dc.mass;
|
|
}
|
|
|
|
}
|