public override void OnInspectorGUI() { if (UC_EditorUtility.DisplayScriptField(this)) { return; } if (script == null) { script = (BaseSnapPoint)target; } script.receiveType = (BuildingType)EditorGUILayout.EnumMaskField("Receive :", script.receiveType); if (GUI.changed) { EditorUtility.SetDirty(target); } }
/// <summary> /// Return the closest point to the target from the points. /// </summary> /// <param name="points">our snap points.</param> /// <returns>closest snap point to the target.</returns> public static BaseSnapPoint ReturnClosest(BaseSnapPoint[] points, Vector3 pointInfluence, BuildingType type) { BaseSnapPoint closestPoint = null; float closestRange = 999; BaseSnapPoint point; float distance = 0.0f; for (int i = 0; i < points.Length; i++) { point = points[i]; distance = point.ReturnDistance(pointInfluence); if (distance <= closestRange && FlagsHelper.IsBitSet <BuildingType>(point.receiveType, type)) { closestPoint = point; closestRange = distance; } } return(closestPoint); }