FindNearestPivot() приватный статический Метод

private static FindNearestPivot ( Transform transforms, Vector2 screenPosition ) : Vector3
transforms UnityEngine.Transform
screenPosition Vector2
Результат Vector3
Пример #1
0
        private static void UpdateVertexSnappingOffset()
        {
            Event current = Event.current;

            Tools.vertexDragging = true;
            Transform[] transforms = Selection.GetTransforms((SelectionMode)14);
            HandleUtility.ignoreRaySnapObjects = null;
            Vector3 vector = VertexSnapping.FindNearestPivot(transforms, current.mousePosition);
            Vector3 vector2;
            bool    flag       = HandleUtility.FindNearestVertex(current.mousePosition, transforms, out vector2);
            float   magnitude  = (HandleUtility.WorldToGUIPoint(vector2) - current.mousePosition).magnitude;
            float   magnitude2 = (HandleUtility.WorldToGUIPoint(vector) - current.mousePosition).magnitude;
            Vector3 a;

            if (flag && magnitude < magnitude2)
            {
                a = vector2;
            }
            else
            {
                a = vector;
            }
            Tools.handleOffset = Vector3.zero;
            Tools.handleOffset = a - Tools.handlePosition;
        }
Пример #2
0
        private static void UpdateVertexSnappingOffset()
        {
            Event current = Event.current;

            Tools.vertexDragging = true;
            Transform[] transforms = Selection.GetTransforms(SelectionMode.Deep | SelectionMode.ExcludePrefab | SelectionMode.Editable);
            HandleUtility.ignoreRaySnapObjects = (Transform[])null;
            Vector3 nearestPivot = VertexSnapping.FindNearestPivot(transforms, current.mousePosition);
            Vector3 vertex;
            Vector3 vector3 = !HandleUtility.FindNearestVertex(current.mousePosition, transforms, out vertex) || (double)(HandleUtility.WorldToGUIPoint(vertex) - current.mousePosition).magnitude >= (double)(HandleUtility.WorldToGUIPoint(nearestPivot) - current.mousePosition).magnitude ? nearestPivot : vertex;

            Tools.handleOffset = Vector3.zero;
            Tools.handleOffset = vector3 - Tools.handlePosition;
        }