Exemplo n.º 1
0
        protected virtual void RefreshLocalContent()
        {
            // Set the scale of the pivot
            contentParent.transform.localScale = Vector3.one * contentScale;
            label.transform.localScale         = Vector3.one * 0.005f;
            // Set the content using a text mesh by default
            // This function can be overridden for tooltips that use Unity UI
            TextMesh text = label.GetComponent <TextMesh>();

            if (text != null && !string.IsNullOrEmpty(toolTipText))
            {
                text.fontSize    = fontSize;
                text.text        = toolTipText.Trim();
                text.lineSpacing = 1;
                text.anchor      = TextAnchor.MiddleCenter;
                // Get the world scale of the text
                // Convert that to local scale using the content parent
                Vector3 localScale = text.transform.localScale;
                localContentSize.x = localScale.x + backgroundPadding.x;
                localContentSize.y = localScale.y + backgroundPadding.y;
            }
            // Now that we have the size of our content, get our pivots
            ToolTipUtility.GetAttachPointPositions(ref localAttachPointPositions, localContentSize);
            localAttachPoint = ToolTipUtility.FindClosestAttachPointToAnchor(anchor.transform, contentParent.transform, localAttachPointPositions, attachPointType);
        }
        protected virtual void OnSceneGUI()
        {
            if (DrawAttachPoints)
            {
                Handles.color = Color.Lerp(Color.clear, Color.red, 0.5f);
                float scale = toolTip.ContentScale * 0.01f;

                ToolTipUtility.GetAttachPointPositions(ref localAttachPointPositions, toolTip.LocalContentSize);
                foreach (Vector3 attachPoint in localAttachPointPositions)
                {
                    Handles.SphereHandleCap(0, toolTip.ContentParentTransform.TransformPoint(attachPoint), Quaternion.identity, scale, EventType.Repaint);
                }
            }
        }
Exemplo n.º 3
0
        protected virtual void Update()
        {
            // Enable / disable our line if it exists
            if (toolTipLine != null)
            {
                toolTipLine.enabled    = IsOn;
                toolTipLine.FirstPoint = AnchorPosition;
                toolTipLine.LastPoint  = AttachPointPosition;
            }

            if (IsOn)
            {
                contentParent.SetActive(true);
                localAttachPoint = ToolTipUtility.FindClosestAttachPointToAnchor(anchor.transform, contentParent.transform, localAttachPointPositions, attachPointType);
            }
            else
            {
                contentParent.SetActive(false);
            }
        }
Exemplo n.º 4
0
        protected virtual void OnSceneGUI()
        {
            if (DrawAttachPoints)
            {
                Handles.color = Color.Lerp(Color.clear, Color.red, 0.5f);
                float scale = externalPlot.ContentScale * 0.01f;

                ToolTipUtility.GetAttachPointPositions(ref localAttachPointPositions, externalPlot.LocalContentSize);
                foreach (Vector3 attachPoint in localAttachPointPositions)
                {
                    Handles.SphereHandleCap(0, externalPlot.ContentParentTransform.TransformPoint(attachPoint), Quaternion.identity, scale, EventType.Repaint);
                }
            }

            if (DrawHandles)
            {
                ExternalPlot externalPlot = (ExternalPlot)target;
                float        handleSize   = 0;
                float        arrowSize    = 0;

                BaseMixedRealityLineDataProvider line = externalPlot.GetComponent <BaseMixedRealityLineDataProvider>();
                if (line == null)
                {
                    Handles.color = Color.white;
                    Handles.DrawDottedLine(externalPlot.AnchorPosition, externalPlot.AttachPointPosition, 5f);
                }

                EditorGUI.BeginChangeCheck();

                Handles.color = Color.cyan;
                handleSize    = HandleUtility.GetHandleSize(externalPlot.PivotPosition) * handleSizeMultiplier;
                arrowSize     = handleSize * 2;
                Vector3 newPivotPosition = Handles.FreeMoveHandle(externalPlot.PivotPosition, Quaternion.identity, handleSize, Vector3.zero, Handles.SphereHandleCap);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newPivotPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                Handles.color = Color.white;
                Handles.Label(newPivotPosition + (Vector3.up * arrowSize), "Pivot", EditorStyles.whiteLabel);

                Handles.color = Color.cyan;
                handleSize    = HandleUtility.GetHandleSize(externalPlot.AnchorPosition) * handleSizeMultiplier;
                arrowSize     = handleSize * 2;
                Vector3 newAnchorPosition = Handles.FreeMoveHandle(externalPlot.AnchorPosition, Quaternion.identity, HandleUtility.GetHandleSize(externalPlot.AnchorPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                Handles.ArrowHandleCap(0, newAnchorPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                Handles.color = Color.white;
                Handles.Label(newAnchorPosition + (Vector3.up * arrowSize), "Anchor", EditorStyles.whiteLabel);

                if (EditorGUI.EndChangeCheck())
                {
                    if (newAnchorPosition != externalPlot.AnchorPosition)
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot.Anchor.transform, "Moved Anchor");
                        externalPlot.Anchor.transform.position = newAnchorPosition;
                    }

                    if (newPivotPosition != externalPlot.PivotPosition)
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot.Pivot.transform, "Moved Pivot");
                        externalPlot.Pivot.transform.position = newPivotPosition;
                    }
                }

                if (EditAttachPoint)
                {
                    EditorGUI.BeginChangeCheck();

                    Handles.color = Color.cyan;
                    handleSize    = HandleUtility.GetHandleSize(externalPlot.AttachPointPosition) * handleSizeMultiplier;
                    arrowSize     = handleSize * 2;
                    Vector3 newAttachPointPosition = Handles.FreeMoveHandle(externalPlot.AttachPointPosition, Quaternion.identity, HandleUtility.GetHandleSize(externalPlot.AttachPointPosition) * handleSizeMultiplier, Vector3.zero, Handles.SphereHandleCap);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.up), arrowSize, EventType.Repaint);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.forward), arrowSize, EventType.Repaint);
                    Handles.ArrowHandleCap(0, newAttachPointPosition, Quaternion.LookRotation(Vector3.right), arrowSize, EventType.Repaint);

                    Handles.color = Color.white;
                    Handles.Label(newAttachPointPosition + (Vector3.up * arrowSize), "Attach Point", EditorStyles.whiteLabel);

                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RegisterCompleteObjectUndo(externalPlot, "Moved Attach Point");
                        Undo.RegisterCompleteObjectUndo(externalPlot.Anchor.transform, "Moved Attach Point");
                        externalPlot.AttachPointPosition = newAttachPointPosition;
                    }
                }
            }
        }