21 private bool showBackground =
true;
25 public bool ShowBackground
29 return showBackground;
33 showBackground = value;
34 GetComponent<ToolTipBackgroundMesh>().IsVisible = value;
39 private bool showOutline =
false;
43 public bool ShowOutline
52 GameObject TipBackground = contentParent.transform.GetChild(1).gameObject;
54 rectangle.enabled = value;
59 private bool showConnector =
true;
63 public bool ShowConnector
71 showConnector = value;
73 Line lineScript = GetComponent<Line>();
74 lineScript.enabled = value;
104 groupTipState = value;
108 return groupTipState;
121 masterTipState = value;
125 return masterTipState;
129 [Tooltip(
"GameObject that the line and text are attached to")]
135 public GameObject Anchor
147 [Tooltip(
"Pivot point that text will rotate around as well as the point where the Line will be rendered to.")]
153 public GameObject Pivot
161 [Tooltip(
"GameObject text that is displayed on the tooltip.")]
165 [Tooltip(
"Parent of the Text and Background")]
169 [Tooltip(
"Text for the ToolTip to say")]
176 public string ToolTipText
180 if (value != toolTipText)
183 RefreshLocalContent();
184 if (ContentChange != null)
185 ContentChange.Invoke();
194 [Tooltip(
"The padding around the content (height / width)")]
198 [Tooltip(
"The offset of the background (x / y / z)")]
204 public Vector3 LocalContentOffset
208 return backgroundOffset;
212 [Tooltip(
"The scale of all the content (label, backgrounds, etc.)")]
215 protected float contentScale = 1f;
219 public float ContentScale
227 contentScale = value;
228 RefreshLocalContent();
232 [Tooltip(
"The font size of the tooltip.)")]
235 protected int fontSize = 30;
246 return attachPointType;
250 attachPointType = value;
254 [Tooltip(
"The line connecting the anchor to the pivot. If present, this component will be updated automatically.")]
262 public Vector2 LocalContentSize
266 return localContentSize;
279 public Vector3 PivotPosition
283 return pivot.transform.position;
287 pivot.transform.position = value;
294 public Vector3 AttachPointPosition
298 return contentParent.transform.TransformPoint(localAttachPoint) + attachPointOffset;
303 attachPointOffset = value - contentParent.transform.TransformPoint(localAttachPoint);
310 public Vector3 AnchorPosition
314 return anchor.transform.position;
321 public Transform ContentParentTransform
325 return contentParent.transform;
336 switch (masterTipState)
341 switch (groupTipState)
413 if (toolTipLine == null)
414 toolTipLine = gameObject.GetComponent<
LineBase>();
417 RefreshLocalContent();
418 contentParent.SetActive(
false);
419 ShowBackground = showBackground;
420 ShowOutline = showOutline;
421 ShowConnector = showConnector;
426 if (toolTipLine != null)
428 toolTipLine.enabled = IsOn;
430 toolTipLine.
LastPoint = AttachPointPosition;
434 contentParent.SetActive(
true);
437 contentParent.SetActive(
false);
444 contentParent.transform.localScale = Vector3.one * contentScale;
445 label.transform.localScale = Vector3.one * 0.005f;
448 TextMesh text = label.GetComponent<TextMesh>();
449 if (text != null && !
string.IsNullOrEmpty(toolTipText)) {
450 text.fontSize = fontSize;
451 text.text = toolTipText.Trim();
452 text.lineSpacing = 1;
453 text.anchor = TextAnchor.MiddleCenter;
456 Vector3 localScale = text.transform.localScale;
457 localContentSize.x = localScale.x + backgroundPadding.x;
458 localContentSize.y = localScale.y + backgroundPadding.y;
467 Transform pivotTransform = transform.Find(
"Pivot");
468 Transform anchorTransform = transform.Find(
"Anchor");
469 if (pivotTransform == null || anchorTransform == null) {
470 if (Application.isPlaying) {
471 Debug.LogError(
"Found error in heirarchy, disabling.");
476 Transform contentParentTransform = pivotTransform.Find(
"ContentParent");
477 if (contentParentTransform == null) {
478 if (Application.isPlaying) {
479 Debug.LogError(
"Found error in heirarchy, disabling.");
484 Transform labelTransform = contentParentTransform.Find(
"Label");
485 if (labelTransform == null) {
486 if (Application.isPlaying) {
487 Debug.LogError(
"Found error in heirarchy, disabling.");
493 contentParentTransform.localPosition = Vector3.zero;
494 contentParentTransform.localRotation = Quaternion.identity;
495 contentParentTransform.localScale = Vector3.one * contentScale;
496 labelTransform.localPosition = Vector3.zero;
497 labelTransform.localScale = Vector3.one * 0.025f;
498 labelTransform.localRotation = Quaternion.identity;
499 pivotTransform.localScale = Vector3.one;
501 pivot = pivotTransform.gameObject;
502 anchor = anchorTransform.gameObject;
503 contentParent = contentParentTransform.gameObject;
504 label = labelTransform.gameObject;
510 private void OnDrawGizmos() {
512 if (Application.isPlaying)
515 if (!EnforceHierarchy()) {
519 RefreshLocalContent();
521 if (toolTipLine != null)
524 toolTipLine.
LastPoint = AttachPointPosition;