IEnumerator HideCoroutine(bool fast) { IsMoving = true; _backCloseImage.raycastTarget = false; if (_animType == PopupAnimTypes.Move) { Vector2 pos = _initPos; if (!_moveHor) { pos.y += _moveDir * _backCloseRect.height; } else { pos.x += _moveDir * _backCloseRect.height; } if (!fast) { _frameRectTr.DOAnchorPos(pos, _animTime).SetEase(Ease.InBack); } else { _frameRectTr.anchoredPosition = pos; } } if (_animType == PopupAnimTypes.Scale) { _frameRectTr.localScale = Vector3.one; _frameRectTr.DOScale(Vector3.one * .1f, _animTime).SetEase(Ease.InBack); } _backCloseImage.DOFade(0, !fast ? _animTime : 0).SetEase(Ease.Linear); yield return(new WaitForSeconds(_animTime)); IsBusy = false; s_popupsList.Remove(this); IsMoving = false; gameObject.SetActive(_avtiveWhenHidden); HideEvent?.Invoke(); }
void Update() { transform.position = Input.mousePosition; if (collideObj != null) { collideObj.transform.position = _cameraMain.ScreenToWorldPoint(transform.position); } if (Input.GetMouseButtonUp(0)) { // StartCoroutine(DestroyInNextFrame()); collideObj.GetComponent <RangeIndicatorCollideObj>().Run(useAction); Destroy(gameObject); HideEvent?.Invoke(); } }
public void Hide() { if (HookCursor) { Cursor.visible = _wasCursorVisible; } if (LockInput) { if (_wasLocked) { InputUtil.Instance.UnlockInput(this); } _wasLocked = false; } Draw = false; HideEvent.Invoke(); }
protected void OnHideEvent(WindowInfoWithHandle windowInfo) { HideEvent?.Invoke(this, new OriginalWinEventArg(windowInfo)); }
public PopupLayout() { // 点击手势 var tap = new TapGestureRecognizer(); // 点击手势响应事件 tap.Tapped += async(sender, e) => { HideEvent?.Invoke(sender, e); await HidePopup(); }; // 绝对布局添加点击手势 _canvasView.GestureRecognizers.Add(tap); // 画布定位方式(大小按比例) _canvasView.SetValue(AbsoluteLayout.LayoutFlagsProperty, AbsoluteLayoutFlags.SizeProportional); // 画布定位 _canvasView.SetValue(AbsoluteLayout.LayoutBoundsProperty, new Rectangle(0, 0, 1, 1)); // 将画布添加到绝对布局中 _absoluteLayout.Children.Add(_canvasView); // 弹窗列表改变事件 PopupItems.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => { var items = (ObservableCollection <PopupItem>)sender; foreach (var item in items) { var view = item.Content; if (!_absoluteLayout.Children.Contains(view)) { // 设置不可见 view.IsVisible = false; // 设置透明度0 view.Opacity = 1; // 弹窗定位方式(绝对定位) view.SetValue(AbsoluteLayout.LayoutFlagsProperty, AbsoluteLayoutFlags.None); // 将弹窗添加进绝对布局 _absoluteLayout.Children.Add(view); } } }; // 画布绘图事件 _canvasView.PaintSurface += (sender, e) => { // 获取画布实例 var canvas = e.Surface.Canvas; // 清除画布 canvas.Clear(); if (!_isDrawTriangle) { return; } // 计算画布上的画图区域 var rect = new Rectangle(_rect.X / Width * e.Info.Width, _rect.Y / Height * e.Info.Height, _rect.Width / Width * e.Info.Width, _rect.Height / Height * e.Info.Height); _drawX = _drawX / Width * e.Info.Width; // 实例化刷子 var paint = new SKPaint { Style = SKPaintStyle.StrokeAndFill, Color = SKColors.Gainsboro, IsAntialias = true }; // 实例化路径 var path = new SKPath(); // 箭头方向向上 if (_isArrowUp) { // 绘制路径 path.MoveTo((float)(_drawX + 15), (float)(rect.Y)); path.LineTo((float)(_drawX + 30), (float)(rect.Y - 20)); path.LineTo((float)(_drawX + 45), (float)(rect.Y)); path.LineTo((float)(rect.X + rect.Width), (float)(rect.Y)); path.LineTo((float)(rect.X + rect.Width), (float)(rect.Y + rect.Height)); path.LineTo((float)(rect.X), (float)(rect.Y + rect.Height)); path.LineTo((float)(rect.X), (float)(rect.Y)); path.Close(); } else { // 绘制路径 path.MoveTo((float)(_drawX + 15), (float)(rect.Y + rect.Height)); path.LineTo((float)(_drawX + 30), (float)(rect.Y + rect.Height + 20)); path.LineTo((float)(_drawX + 45), (float)(rect.Y + rect.Height)); path.LineTo((float)(rect.X + rect.Width), (float)(rect.Y + rect.Height)); path.LineTo((float)(rect.X + rect.Width), (float)(rect.Y)); path.LineTo((float)(rect.X), (float)(rect.Y)); path.LineTo((float)(rect.X), (float)(rect.Y + rect.Height)); path.Close(); } // 按路径绘图 canvas.DrawPath(path, paint); }; }