using System.Collections; using System.Collections.Generic; using UnityEngine; public class WaterDisTest : MonoBehaviour { WaterManager[] distanceManagers; // Start is called before the first frame update void Start() { distanceManagers = GameObject.FindObjectsOfType(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { WaterManager nearWater = ArrayHelper.Min(distanceManagers, (p) => p.GetDistanceFromWater(this.transform.position)); Debug.Log(nearWater.name); float distance = nearWater.GetNearestPointDistance(this.transform.position); } } }