public SnapToGuides ( float value, float snapDistance ) : float | ||
value | float | |
snapDistance | float | |
Результат | float |
public float SnapToGuides(float value, float snapDistance)
{
if (this.guides.Count != 0)
{
KeyValuePair<float, List<SnapGuide>> pair = new KeyValuePair<float, List<SnapGuide>>();
float positiveInfinity = float.PositiveInfinity;
foreach (KeyValuePair<float, List<SnapGuide>> pair2 in this.guides)
{
float num3 = Mathf.Abs((float) (value - pair2.Key));
if (num3 < positiveInfinity)
{
pair = pair2;
positiveInfinity = num3;
}
}
if (positiveInfinity <= snapDistance)
{
value = pair.Key;
this.currentGuides = pair.Value;
}
else
{
this.currentGuides = null;
}
}
return value;
}
}
internal static float SnapToGuides(float value, float snapDistance, int axis) { if (EditorGUI.actionKey) { return(value); } SnapGuideCollection snapGuideCollection = (axis != 0) ? RectTransformSnapping.s_SnapGuides[1] : RectTransformSnapping.s_SnapGuides[0]; return(snapGuideCollection.SnapToGuides(value, snapDistance)); }