private void OnDrawGizmos() { if (Application.isPlaying) { return; } if (gameObject == UnityEditor.Selection.activeGameObject) { Gizmos.color = Color.cyan; Transform relativeTo = null; switch (pivotDirectionOrient) { case ToolTipConnector.ConnectorOrientType.OrientToCamera: relativeTo = Camera.main.transform; //Veil.Instance.HeadTransform; break; case ToolTipConnector.ConnectorOrientType.OrientToObject: relativeTo = (Anchor != null) ? Anchor.transform : transform; break; } if (pivotMode == ToolTipConnector.ConnnectorPivotMode.Automatic) { Vector3 targetPosition = (Anchor != null) ? Anchor.transform.position : transform.position; Vector3 toolTipPosition = targetPosition + ToolTipConnector.GetDirectionFromPivotDirection( pivotDirection, manualPivotDirection, relativeTo) * pivotDistance; Gizmos.DrawLine(targetPosition, toolTipPosition); Gizmos.DrawWireCube(toolTipPosition, Vector3.one * 0.05f); } else { Vector3 targetPosition = (Anchor != null) ? Anchor.transform.position : transform.position; Vector3 toolTipPosition = transform.TransformPoint(manualPivotLocalPosition); Gizmos.DrawLine(targetPosition, toolTipPosition); Gizmos.DrawWireCube(toolTipPosition, Vector3.one * 0.05f); } } }
private IEnumerator UpdateTooltip(float focusEnterTimeOnStart, float tappedTimeOnStart) { if (toolTip == null) { GameObject toolTipGo = GameObject.Instantiate(toolTipPrefab) as GameObject; toolTip = toolTipGo.GetComponent <ToolTip>(); toolTip.gameObject.SetActive(false); toolTip.ShowBackground = showBackground; toolTip.ShowOutline = showOutline; toolTip.ShowConnector = showConnector; toolTip.transform.position = transform.position; toolTip.transform.parent = transform; toolTip.ContentParentTransform.localScale = defaultDimensions; } if (appearType == AppearType.AppearOnFocusEnter) { // Wait for the appear delay yield return(new WaitForSeconds(appearDelay)); // If we don't have focus any more, get out of here if (!hasFocus) { yield break; } } toolTip.ToolTipText = ToolTipText; toolTip.gameObject.SetActive(true); ToolTipConnector connector = toolTip.GetComponent <ToolTipConnector>(); connector.Target = (Anchor != null) ? Anchor.gameObject : gameObject; connector.PivotDirection = pivotDirection; connector.PivotDirectionOrient = pivotDirectionOrient; connector.ManualPivotLocalPosition = manualPivotLocalPosition; connector.ManualPivotDirection = manualPivotDirection; connector.FollowingType = followType; connector.PivotingMode = pivotMode; if (pivotMode == ToolTipConnector.ConnnectorPivotMode.Manual) { toolTip.PivotPosition = transform.TransformPoint(manualPivotLocalPosition); } while (toolTip.gameObject.activeSelf) { if (remainType == RemainType.Timeout) { if (appearType == AppearType.AppearOnTap) { if (Time.unscaledTime - tappedTime >= lifetime) { toolTip.gameObject.SetActive(false); yield break; } } else if (appearType == AppearType.AppearOnFocusEnter) { if (Time.unscaledTime - focusEnterTime >= lifetime) { toolTip.gameObject.SetActive(false); yield break; } } } //check whether we're suppose to disappear switch (vanishType) { case VanishType.VanishOnFocusExit: break; case VanishType.VanishOnTap: if (tappedTime != tappedTimeOnStart) { toolTip.gameObject.SetActive(false); } break; default: if (!hasFocus) { if (Time.time - focusExitTime > vanishDelay) { toolTip.gameObject.SetActive(false); } } break; } yield return(null); } yield break; }