private IEnumerator WaitSetPos(RectTransform targetRect, TipAlignment alig, Vector2 offset) { yield return(new WaitForEndOfFrame()); SetPos(targetRect, alig, offset); m_Rect.localScale = Vector3.one; }
/// <summary> /// 传数据给item /// </summary> /// <param name="data">传递给item的数据</param> public override void SetData(object[] data) { m_strTitle = data[0] as string; m_strContext = data[1] as string; m_targetRect = data[2] as RectTransform; m_tipAlignment = (TipAlignment)data[3]; m_offset = (Vector2)data[4]; }
/// <summary> /// 显示tips /// </summary> /// <param name="msg">tip 内容</param> /// <param name="title">tip 标题</param> /// <param name="tipRect">弹出tips 的对象</param> /// <param name="align">对其方式</param> /// <param name="offset">修正偏移值</param> /// <returns></returns> public static bool ShowTips(string msg, string title, RectTransform tipRect, TipAlignment align, Vector2 offset) { ResourceManger.LoadWndItem("HintItem", (WndManager.GetUINode() as UINode).GetWndParent(WndType.DialogWnd), false, (obj) => { HintItem item = obj.GetComponent <HintItem>(); if (item != null) { item.SetData(new object[] { msg, title, tipRect, align, offset }); } }); return(true); }
private void SetPos(RectTransform targetRect, TipAlignment alig, Vector2 offset) { Vector3 targetScreenPos = (WndManager.GetUINode() as UINode).UICamera.WorldToScreenPoint(targetRect.position); Vector3 pos = (WndManager.GetUINode() as UINode).UICamera.WorldToScreenPoint(m_Rect.position); Vector2 center = targetScreenPos - pos; Vector2 v = GetPivotWH(m_Rect, targetRect); if (alig == TipAlignment.Left) { center.x -= v.x; } else if (alig == TipAlignment.Right) { center.x += v.x; } else if (alig == TipAlignment.Up) { center.y += v.y; } else if (alig == TipAlignment.Down) { center.y -= v.y; } else if (alig == TipAlignment.LeftUp) { center.x -= v.x; center.y += v.y; } else if (alig == TipAlignment.LeftDown) { center.x -= v.x; center.y -= v.y; } else if (alig == TipAlignment.RightUp) { center.x += v.x; center.y += v.y; } else if (alig == TipAlignment.RightDown) { center.x += v.x; center.y -= v.y; } m_Rect.localPosition = center + offset; center = m_Rect.localPosition; offset = GetoffScreenOut(m_Rect); m_Rect.localPosition = center + offset; }
/// <summary> /// 传数据给item /// </summary> /// <param name="data">传递给item的数据</param> public override void SetData(object[] data) { m_Type = (int)data[0]; m_Data = data[1] as TargetHeroInfo; if (m_Type == 0) { m_targetRect = data[2] as RectTransform; } else { m_ScreenPos = (Vector2)data[2]; } m_tipAlignment = (TipAlignment)data[3]; m_offset = (Vector2)data[4]; m_IsTouchDestrory = (bool)data[5]; RefreshUI(); }
private void SetPos(RectTransform targetRect, TipAlignment alig, Vector2 offset) { m_Rect.position = targetRect.position; var position = m_Rect.localPosition; position.y = position.y - targetRect.sizeDelta.y / 2 - m_Rect.sizeDelta.y / 2; position.x = position.x + m_Rect.sizeDelta.x / 2 - targetRect.sizeDelta.x / 2; m_Rect.localPosition = position + new Vector3(offset.x, offset.y); //Vector3 targetScreenPos = (WndManager.GetUINode() as UINode).UICamera.WorldToScreenPoint(targetRect.position); //Vector3 pos = (WndManager.GetUINode() as UINode).UICamera.WorldToScreenPoint(m_Rect.position); //Vector2 center = targetScreenPos - pos; //Vector2 v = GetPivotWH(m_Rect, targetRect); //if (alig == TipAlignment.Left) { // center.x -= v.x; //} else if (alig == TipAlignment.Right) { // center.x += v.x; //} else if (alig == TipAlignment.Up) { // center.y += v.y; //} else if (alig == TipAlignment.Down) { // center.y -= v.y; //} else if (alig == TipAlignment.LeftUp) { // center.x -= v.x; // center.y += v.y; //} else if (alig == TipAlignment.LeftDown) { // center.x -= v.x; // center.y -= v.y; //} else if (alig == TipAlignment.RightUp) { // center.x += v.x; // center.y += v.y; //} else if (alig == TipAlignment.RightDown) { // center.x += v.x; // center.y -= v.y; //} //m_Rect.localPosition = center + offset; //center = m_Rect.localPosition; //offset = GetoffScreenOut(m_Rect); //m_Rect.localPosition = center + offset; }
/// <summary> /// 显示敌我目标tips /// </summary> /// <param name="Info">目标数据</param> /// <param name="ScreenPos">屏幕位置</param> /// <param name="align">对其方式</param> /// <param name="TargetSize">触碰3D对象的在屏幕中的大小</param> /// <param name="isTouchDestroy">是否触碰销毁</param> /// <returns></returns> public static void ShowTargetTips(TargetHeroInfo Info, Vector2 ScreenPos, TipAlignment align, Vector2 TargetSize, bool isTouchDestroy) { WndManager.CreateWnd <TargetInfoWnd>(WndType.DialogWnd, false, false, (wnd) => { (wnd as TargetInfoWnd).SetData(new object[] { 1, Info, ScreenPos, align, TargetSize, isTouchDestroy }); }); }
/// <summary> /// 显示敌我目标tips /// </summary> /// <param name="Info">目标数据</param> /// <param name="tipRect">弹出tips的控件对象</param> /// <param name="align">对其方式</param> /// <param name="isTouchDestroy">是否触碰销毁</param> /// <returns></returns> public static void ShowTargetTips(TargetHeroInfo Info, RectTransform tipRect, TipAlignment align, Vector2 offset, bool isTouchDestroy) { WndManager.DestoryWnd <TargetInfoWnd>(); WndManager.CreateWnd <TargetInfoWnd>(WndType.DialogWnd, false, false, (wnd) => { (wnd as TargetInfoWnd).SetData(new object[] { 0, Info, tipRect, align, offset, isTouchDestroy }); }); }
/// <summary> /// BorderPath_SizeChanged /// </summary> /// <param name="sender">This is a parameter with a type of object</param> /// <param name="e">This is a parameter with a type of RoutedEventArgs</param> private void BorderPath_SizeChanged(object sender, RoutedEventArgs e) { if (this.BorderPath.Parent is FrameworkElement) { FrameworkElement p = BorderPath.Parent as FrameworkElement; if (p.ActualWidth > 0 && p.ActualHeight > 0) { double pointX = p.ActualWidth; double pointY = p.ActualHeight; RectangleGeometry g1 = new RectangleGeometry(new Rect(new Point(0, 0), new Point(pointX - Offset, pointY - Offset))); PathGeometry g2 = new PathGeometry(); if (ShowTip) { PathFigure p1 = new PathFigure(); Point startPoint; Point midPoint; Point endPoint; if (TipAlignment.Equals("Top")) { double top = pointY - TipHeight - Offset; g1 = new RectangleGeometry(new Rect(new Point(0, 0), new Point(pointX - Offset, top))); startPoint = new Point(TipOffSet, top); midPoint = new Point(TipWidth / 2 + TipOffSet, top + TipHeight); endPoint = new Point(TipWidth + TipOffSet, top); } else if (TipAlignment.Equals("Bottom")) { double bottom = TipHeight; g1 = new RectangleGeometry(new Rect(new Point(0, bottom), new Point(pointX, pointY))); startPoint = new Point(0 + TipOffSet, bottom); midPoint = new Point(TipWidth / 2 + TipOffSet, 0); endPoint = new Point(TipWidth + TipOffSet, bottom); } else if (TipAlignment.Equals("Left")) { double left = TipHeight; g1 = new RectangleGeometry(new Rect(new Point(left, 0), new Point(pointX, pointY))); startPoint = new Point(left, TipOffSet); midPoint = new Point(0, TipWidth / 2 + TipOffSet); endPoint = new Point(left, TipWidth + TipOffSet); } else { ////this.tipAlignment equals TipAlignmentType.Right double right = pointX - TipHeight; g1 = new RectangleGeometry(new Rect(new Point(0, 0), new Point(right, pointY))); startPoint = new Point(right, TipOffSet); midPoint = new Point(pointX, TipWidth / 2 + TipOffSet); endPoint = new Point(right, TipWidth + TipOffSet); } p1.StartPoint = startPoint; LineSegment l1 = new LineSegment(midPoint, true); LineSegment l2 = new LineSegment(endPoint, true); p1.Segments.Add(l1); p1.Segments.Add(l2); g2.Figures.Add(p1); BorderPath.Data = new CombinedGeometry(GeometryCombineMode.Union, g1, g2); } else { BorderPath.Data = g1; } if (EnableDropShadow) { if (ShowTip) { BorderPathShadow.Data = new CombinedGeometry(GeometryCombineMode.Union, g1, g2); } else { if (isPopup) { //popup BorderPathShadow.Data = g1; } else { //images,watermark textbox BorderPathShadow.Data = new RectangleGeometry(new Rect(new Point(0, 0), new Point(pointX, pointY))); } } BorderPathShadow.Style = this.FindResource(ShadowStyle) as Style; } } } }