Exemple #1
0
        public override void Transition(UiRegion region, out Tween tween)
        {
            Vector3 idlePos = region.idleLocalPosition;

            RectTransform rectT = region.transform as RectTransform;

            Debug.Assert(rectT != null, nameof(rectT) + " != null");

            float distance = rectT.rect.height;

            region.transform.DOComplete();

            //change in/out direction
            if (inverse)
            {
                tween = rectT.DOLocalMoveY(direction ? idlePos.y : idlePos.y - distance, duration);
            }

            else
            {
                tween = rectT.DOLocalMoveY(direction ? idlePos.y + distance : idlePos.y, duration);
            }

            //Vector3 rootPosition = new Vector3(0, (Screen.height / 2f) - (distance / 2f), 0);

            //if (transform.localPosition.y < 0)
            //{
            //    rootPosition *= -1f;
            //}

            //Vector3 endPosition = new Vector3(0, transform.localPosition.y < 0 ? rootPosition.y - distance : rootPosition.y + distance, 0);

            //tween = rectT.DOLocalMove(Direction ? rootPosition : endPosition, Duration);
        }
Exemple #2
0
 private bool FindImage()
 {
     //find image
     uiNode.clippingRegion = null;
     try
     {
         UiRegion imageRegion = uiNode.FindImage(image, GetAccuracy());
         if (imageRegion != null)
         {
             uiNode.clippingRegion = imageRegion;
         }
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Exemple #3
0
        public override void Transition(UiRegion region, out Tween tween)
        {
            Vector3 idlePos = region.idleLocalPosition;

            RectTransform rectT = region.transform as RectTransform;

            Debug.Assert(rectT != null, nameof(rectT) + " != null");

            float distance = rectT.rect.width;

            region.transform.DOComplete();

            //change in/out direction
            if (inverse)
            {
                tween = rectT.DOLocalMoveX(direction ? idlePos.x : idlePos.x - distance, duration);
            }

            else
            {
                tween = rectT.DOLocalMoveX(direction ? idlePos.x + distance : idlePos.x, duration);
            }
        }
Exemple #4
0
 public override void Transition(UiRegion region, out Tween tween)
 {
     tween = region.transform.DOScale(direction ? Vector3.one : Vector3.zero, duration);
 }
Exemple #5
0
        private void ClickImage(UiRegion[] regionCollection, bool hover)
        {
            UiClickType clickType = UiClickType.UI_CLICK_SINGLE;
            UiMouseButton mouseBtn = UiMouseButton.UI_BTN_LEFT;
            UiInputMethod inputMethod = UiInputMethod.UI_HARDWARE_EVENTS;

            //get input parameters
            if (DoubleBtn.Checked)
            {
                clickType = UiClickType.UI_CLICK_DOUBLE;
            }

            if (MiddleMouseBtn.Checked)
            {
                mouseBtn = UiMouseButton.UI_BTN_MIDDLE;
            }
            if (RightMouseBtn.Checked)
            {
                mouseBtn = UiMouseButton.UI_BTN_RIGHT;
            }

            if (Win32MsgBtn.Checked)
            {
                inputMethod = UiInputMethod.UI_WIN32_MSG;
            }
            if (ControlAPIBtn.Checked)
            {
                MessageBox.Show("Please select another input method for click or hover image");
                return;
            }

            try
            {
                if (regionCollection == null)
                {
                    if (!FindImage())
                    {
                        MessageBox.Show("The image was not found");
                        return;
                    }
                }
                if (hover)
                {
                    uiNode.Hover(uiNode.clippingRegion.width / 2, uiNode.clippingRegion.height / 2, inputMethod, 500);
                }
                else
                {
                    //click image
                    if (regionCollection == null)
                    {
                        uiNode.Click(uiNode.clippingRegion.width / 2, uiNode.clippingRegion.height / 2, clickType, mouseBtn, inputMethod);
                    }
                    else
                    {
                        //click all images
                        foreach (UiRegion region in regionCollection)
                        {
                            uiNode.clippingRegion = region;
                            uiNode.Click(uiNode.clippingRegion.width / 2, uiNode.clippingRegion.height / 2, clickType, mouseBtn, inputMethod);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #6
0
 public abstract void Transition(UiRegion region, out Tween tween);
Exemple #7
0
        private void TestBtn_Click(object sender, EventArgs e)
        {
            if (uiNode == null)
            {
                try
                {
                    //first select a control
                    SelectCtrlBtn_Click(null, null);
                    if (!uiNode.IsValid())
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }

            //get wait for ready level
            UiWaitForReadyLevels wfrLevel = UiWaitForReadyLevels.UI_WFR_INTERACTIVE;

            if (NoneBtn.Checked)
            {
                wfrLevel = UiWaitForReadyLevels.UI_WFR_NONE;
            }
            if (CompleteBtn.Checked)
            {
                wfrLevel = UiWaitForReadyLevels.UI_WFR_COMPLETE;
            }

            //get input method
            UiInputMethod inputMethod = UiInputMethod.UI_HARDWARE_EVENTS;

            if (CtrlAPIBtn.Checked)
            {
                inputMethod = UiInputMethod.UI_CONTROL_API;
            }
            if (Win32Msg.Checked)
            {
                inputMethod = UiInputMethod.UI_WIN32_MSG;
            }
            try
            {
                //get control position
                UiRegion position = (UiRegion)uiNode.Get("position");

                //set offsets to the center of the control
                int offsetX = position.width / 2;
                int offsetY = position.height / 2;

                //set wait for ready level
                uiNode.waitForReadyLevel = wfrLevel;

                if (HoverOnlyBtn.Checked)
                {
                    //hover control
                    uiNode.Hover(offsetX, offsetY, inputMethod, 500);
                }
                else
                {
                    //click control
                    //get mouse button
                    UiMouseButton mouseBtn = UiMouseButton.UI_BTN_LEFT;
                    if (RightMouseBtn.Checked)
                    {
                        mouseBtn = UiMouseButton.UI_BTN_RIGHT;
                    }
                    if (MiddleMouseBtn.Checked)
                    {
                        mouseBtn = UiMouseButton.UI_BTN_MIDDLE;
                    }

                    //get click type
                    UiClickType clickType = UiClickType.UI_CLICK_SINGLE;
                    if (DoubleButton.Checked)
                    {
                        clickType = UiClickType.UI_CLICK_DOUBLE;
                    }

                    uiNode.Click(offsetX, offsetY, clickType, mouseBtn, inputMethod);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }