/// <summary> /// Updates the tooltip position. /// </summary> public virtual void UpdatePositionAndPivot() { // Update the tooltip position to the mosue position // If the tooltip is not anchored to a target // Anchored position should be updated after updating the pivot if (this.m_AnchorToTarget == null) { // Convert the offset based on the pivot Vector3 pivotBasedOffset = new Vector3(((this.m_Rect.pivot.x == 1f) ? (this.m_Offset.x * -1f) : this.m_Offset.x), ((this.m_Rect.pivot.y == 1f) ? (this.m_Offset.y * -1f) : this.m_Offset.y), 0f); // Update the position including the offset this.m_Rect.position = pivotBasedOffset + Input.mousePosition; } // Update the tooltip pivot this.UpdatePivot(); // Check if we are anchored to a rect if (this.m_AnchorToTarget != null) { // Set the anchor position to the opposite of the tooltip's pivot Vector3[] targetWorldCorners = new Vector3[4]; this.m_AnchorToTarget.GetWorldCorners(targetWorldCorners); // Convert the tooltip pivot to corner Corner pivotCorner = UITooltip.VectorPivotToCorner(this.m_Rect.pivot); // Get the opposite corner of the pivot corner Corner oppositeCorner = UITooltip.GetOppositeCorner(pivotCorner); // Convert the offset based on the pivot Vector3 pivotBasedOffset = new Vector3(((this.m_Rect.pivot.x == 1f) ? (this.m_AnchoredOffset.x * -1f) : this.m_AnchoredOffset.x), ((this.m_Rect.pivot.y == 1f) ? (this.m_AnchoredOffset.y * -1f) : this.m_AnchoredOffset.y), 0f); // Update the position this.transform.position = pivotBasedOffset + targetWorldCorners[(int)oppositeCorner]; } }