Exemplo n.º 1
0
        protected void PaintSideLength(Camera camera, Vector3 edgeCenter, Vector3 circleCenter, float length, string name)
        {
            var textCenter2DA = HandleUtility.WorldToGUIPoint(circleCenter);
            var textCenter2DB = HandleUtility.WorldToGUIPoint(edgeCenter);
            var normal2D      = (textCenter2DB - textCenter2DA).normalized;

            var textCenter2D = textCenter2DB;

            textCenter2D += normal2D * (hover_text_distance * 2);

            var textCenterRay = HandleUtility.GUIPointToWorldRay(textCenter2D);
            var textCenter    = textCenterRay.origin + textCenterRay.direction * ((camera.farClipPlane + camera.nearClipPlane) * 0.5f);

            PaintUtility.DrawLine(edgeCenter, textCenter, Color.black);
            PaintUtility.DrawDottedLine(edgeCenter, textCenter, ColorSettings.SnappedEdges);

            if (float.IsNaN(length) || float.IsInfinity(length))
            {
                PaintUtility.DrawScreenText(textCenter2D, name + " --");
            }
            else
            {
                PaintUtility.DrawScreenText(textCenter2D, name + Units.ToRoundedDistanceString(length));
            }
        }
Exemplo n.º 2
0
        protected void PaintHeightMessage(Vector3 start, Vector3 end, Vector3 normal, float distance)
        {
            if (Mathf.Abs(distance) <= MathConstants.EqualityEpsilon)
            {
                return;
            }

            Vector3 middlePoint = (end + start) * 0.5f;

            var textCenter2DA = HandleUtility.WorldToGUIPoint(middlePoint + normal * 10.0f);
            var textCenter2DB = HandleUtility.WorldToGUIPoint(middlePoint);
            var normal2D      = (textCenter2DB - textCenter2DA).normalized;

            var textCenter2D = textCenter2DB;

            textCenter2D += normal2D * (hover_text_distance * 2);

            var textCenterRay = HandleUtility.GUIPointToWorldRay(textCenter2D);
            var textCenter    = textCenterRay.origin + textCenterRay.direction * ((Camera.current.farClipPlane + Camera.current.nearClipPlane) * 0.5f);

            PaintUtility.DrawLine(middlePoint, textCenter, Color.black);
            PaintUtility.DrawDottedLine(middlePoint, textCenter, ColorSettings.SnappedEdges);

            PaintUtility.DrawScreenText(textCenter2D, "Y: " + Units.ToRoundedDistanceString(Mathf.Abs(distance)));
        }