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); } } }
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; } } } }