Exemple #1
0
        public void Show(Func <Vector3?> spawnWorldPositionFunc, string showString, Color color)
        {
            InvokeAfterAllAssetsLoadDone(() =>
            {
                duration = defaultShowDuration;
                Vector3?spawnWorldPosition = spawnWorldPositionFunc();
                if (spawnWorldPosition == null)
                {
                    Reset();
                    return;
                }

                this.spawnUIPosition = CameraUtil.WorldToUIPos(null,
                                                               Client.instance.combat.cameraManager.mainCameraBase.camera, spawnWorldPosition.Value);
                this.textComp.text  = showString;
                this.textComp.color = color;


                this.posDiffX = randomManager.RandomBoolean()
                                        ? randomManager.RandomFloat(30, 100f)
                                        : randomManager.RandomFloat(-100, -30);
                this.posDiffY = randomManager.RandomFloat(50, 100f);

                this.isShowing = true;
                graphicComponent.SetIsShow(true);
                UpdatePos(0);
            });
        }
Exemple #2
0
        public void OnUIRockerPointerDown(PointerEventData eventData)
        {
            if (!this.isEnabled)
            {
                return;
            }
            this.pointId = eventData.pointerId;
            this.uiRockerDownPosInEventData   = eventData.pressPosition;
            this.uiRockerDownAnchoredPosition = CameraUtil.ScreenToUIPos(null, null,
                                                                         new Vector3(eventData.pressPosition.x, eventData.pressPosition.y, 0), this.uiRockerRectTransform.pivot);
            var offset = this.uiRockerRectTransform.pivot - new Vector2(0.5f, 0.5f);             // 还原到点击的位置为中心点
            var uiRockerDownAnchoredPosition = this.uiRockerDownAnchoredPosition +
                                               new Vector2(offset.x * this.uiRockerRectTransform.sizeDelta.x,
                                                           offset.y * this.uiRockerRectTransform.sizeDelta.y);                                       // 还原到点击的位置为中心点

            this.SetUIRockerAnchoredPosition(uiRockerDownAnchoredPosition.x, uiRockerDownAnchoredPosition.y);
            this.bollImage.color = new Color(1, 1, 1, 1);

            if (this.isNeedResponseWithSetAlpha)
            {
                this.canvasGroup.alpha = 1;
            }
        }