public override void OnInspectorGUI() { DrawDefaultInspector(); if (script.movement != null) { GUI.enabled = false; EditorGUILayout.FloatField("movement.moveSpeed", script.movement.moveSpeed); string points = ""; script.points.ForEach(p => { points += p.name + (p == script.point ? " (current)" : "") + "\n"; }); if (points.Length == 0) { points = "(none)"; } EditorGUILayout.LabelField("points", points); // Find the closest one Closest <PushingPoint> closest = PushingPoint.GetClosest(script.points, script.controller.characterCenter, script.interaction.ignoreYAxis); if (closest.valid) { EditorGUILayout.LabelField("closest", closest.obj.name); } GUI.enabled = true; } }
PushingPoint GetClosestPoint() { if (hasPoint) { return(null); } if (inventory && inventory.equipped) { return(null); } if (interaction && interaction.hover) { return(null); } // Remove all invalid points. If for some reason they occur. points.RemoveAll(p => p == null); // Find the closest one Closest <PushingPoint> closest = PushingPoint.GetClosest(points, transform.position, interaction.ignoreYAxis); return(closest.obj); }