Esempio n. 1
0
    private void RedirectScrollEvent(GameObject obj)
    {
        EventTrigger trigger = obj.GetComponent <EventTrigger>();

        EventTrigger.Entry entryScroll = new EventTrigger.Entry
        {
            eventID = EventTriggerType.Scroll
        };
        entryScroll.callback.AddListener((data) => { fileScroll.OnScroll((PointerEventData)data); });

        trigger.triggers.Add(entryScroll);
    }
Esempio n. 2
0
 public void OnScroll(PointerEventData data)
 {
     if (enabled)
     {
         MainScroll.OnScroll(data);
     }
 }
Esempio n. 3
0
        public override void OnScroll(PointerEventData eventData)
        {
            if (!horizontal && Math.Abs(eventData.scrollDelta.x) > Math.Abs(eventData.scrollDelta.y))
            {
                routeToParent = true;
            }
            else if (!vertical && Math.Abs(eventData.scrollDelta.x) < Math.Abs(eventData.scrollDelta.y))
            {
                routeToParent = true;
            }
            else
            {
                routeToParent = false;
            }

            if (routeToParent)
            {
                if (parentScroll != null)
                {
                    parentScroll.OnScroll(eventData);
                }
                else
                {
                    DoForParents <IScrollHandler>((parent) =>
                    {
                        parent.OnScroll(eventData);
                    });
                }
            }
            else
            {
                base.OnScroll(eventData);
            }
        }
 // Allows the scroll view to scroll, even if this object is selected
 public override void OnScroll(PointerEventData eventData)
 {
     if (scrollView != null)
     {
         scrollView.OnScroll(eventData);
     }
 }
Esempio n. 5
0
 public void OnScroll(PointerEventData data)
 {
     if (scrollRect != null)
     {
         scrollRect.OnScroll(data);
     }
 }
 public void OnScroll(PointerEventData eventData)
 {
     if (foundScrollRect)
     {
         scrollRect.OnScroll(eventData);
     }
 }
        void Draw(float horSpeed)
        {
            PointerEventData ped = new PointerEventData(EventSystem.current);

            ped.scrollDelta = new Vector2(horSpeed, 0f);
            _ScrollRect.OnScroll(ped);
            _ScrollRect.velocity = ped.scrollDelta * 7;
        }
 public void OnScroll(PointerEventData data)
 {
     CheckMainScroll();
     if (MainScroll != null)
     {
         MainScroll.OnScroll(data);
     }
 }
 public override void OnScroll(PointerEventData eventData)
 {
     base.OnScroll(eventData);
     if (mScrollRect != null)
     {
         mScrollRect.OnScroll(eventData);
     }
 }
Esempio n. 10
0
    private void Update()
    {
        movement *= inertia;
        PointerEventData pointer = new PointerEventData(EventSystem.current);

        pointer.scrollDelta = new Vector2(0, movement);
        scrollRect.OnScroll(pointer);
    }
Esempio n. 11
0
        public void OnScroll(PointerEventData eventData)
        {
            if (scroller == null)
            {
                return;
            }

            scroller.OnScroll(eventData);
        }
Esempio n. 12
0
    static int OnScroll(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        ScrollRect       obj  = LuaScriptMgr.GetUnityObject <ScrollRect>(L, 1);
        PointerEventData arg0 = LuaScriptMgr.GetNetObject <PointerEventData>(L, 2);

        obj.OnScroll(arg0);
        return(0);
    }
    static int OnScroll(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        ScrollRect       obj  = (ScrollRect)LuaScriptMgr.GetUnityObjectSelf(L, 1, "ScrollRect");
        PointerEventData arg0 = (PointerEventData)LuaScriptMgr.GetNetObject(L, 2, typeof(PointerEventData));

        obj.OnScroll(arg0);
        return(0);
    }
Esempio n. 14
0
        // Makes sure that scroll view's contents are within scroll view's bounds
        internal void EnsureScrollViewIsWithinBounds()
        {
            // When scrollbar is snapped to the very bottom of the scroll view, sometimes OnScroll alone doesn't work
            if (scrollView.verticalNormalizedPosition <= Mathf.Epsilon)
            {
                scrollView.verticalNormalizedPosition = 0.0001f;
            }

            scrollView.OnScroll(nullPointerEventData);
        }
Esempio n. 15
0
        // Makes sure that scroll view's contents are within scroll view's bounds
        public void EnsureScrollViewIsWithinBounds()
        {
            // When scrollbar is snapped to the very bottom of the scroll view, sometimes OnScroll alone doesn't work
            if (scrollView.normalizedPosition.y <= Mathf.Epsilon)
            {
                scrollView.normalizedPosition = new Vector2(scrollView.normalizedPosition.x, 0.001f);
            }

            scrollView.OnScroll(nullPointerEventData);
        }
Esempio n. 16
0
 public virtual void OnScroll(PointerEventData eventData)
 {
     if (m_ScrollRect != null)
     {
         m_ScrollRect.OnScroll(eventData);
     }
     if (m_OnScroll != null)
     {
         m_OnScroll(eventData, this);
     }
 }
Esempio n. 17
0
    void OnHold()
    {
        PointerEventData pe = new PointerEventData(EventSystem.current);

        switch (Dir)
        {
        case Direction.Up:
            pe.scrollDelta = Vector2.up * Speed;
            if (Scroll.vertical && Scroll.verticalNormalizedPosition < 1 + OutLook)
            {
                Scroll.OnScroll(pe);
            }
            break;

        case Direction.Down:
            pe.scrollDelta = Vector2.down * Speed;
            if (Scroll.vertical && Scroll.verticalNormalizedPosition > 0 - OutLook)
            {
                Scroll.OnScroll(pe);
            }
            break;

        case Direction.Left:
            pe.scrollDelta = Vector2.left * Speed;
            if (Scroll.horizontal && Scroll.horizontalNormalizedPosition < 1 + OutLook)
            {
                Scroll.OnScroll(pe);
            }
            break;

        case Direction.Right:
            pe.scrollDelta = Vector2.right * Speed;
            if (Scroll.horizontal && Scroll.horizontalNormalizedPosition > 0 - OutLook)
            {
                Scroll.OnScroll(pe);
            }
            break;
        }
    }
Esempio n. 18
0
    public CardActions getListCardActions(CardGameObject cardGameObject)
    {
        CardActions actions = new CardActions();

        copyOverActions(cardGameObject, actions);
        ScrollRect mainScroll = cardGameObject.transform.GetComponentInParent <ScrollRect>();

        actions.onScrollAction = (PointerEventData data) =>
        {
            mainScroll.OnScroll(data);
        };
        return(actions);
    }
    public override void OnScroll(PointerEventData eventData)
    {
        base.OnScroll(eventData);

        if (null != _cachedScrollRect)
        {
            _cachedScrollRect.OnScroll(eventData);
        }

        if (null != OnWheelScroll)
        {
            OnWheelScroll(eventData);
        }
    }
Esempio n. 20
0
    public void OnScrollClampedShouldClampContentAnchoredPosition(ScrollRect.MovementType movementType, float anchoredPosX,
                                                                  float anchoredPosY)
    {
        ScrollRect scrollRect  = m_PrefabRoot.GetComponentInChildren <ScrollRect>();
        Vector2    scrollDelta = new Vector2(50, -50);

        scrollRect.movementType             = movementType;
        scrollRect.content.anchoredPosition = new Vector2(2.5f, 2.5f);

        scrollRect.OnScroll(new PointerEventData(m_PrefabRoot.GetComponentInChildren <EventSystem>())
        {
            scrollDelta = scrollDelta
        });
        Assert.AreEqual(new Vector2(anchoredPosX, anchoredPosY), scrollRect.content.anchoredPosition);
    }
Esempio n. 21
0
        public void OnScroll(PointerEventData data)
        {
            // try to find the parent ScrollRect
            if (m_parentScroller == null)
            {
                m_parentScroller = GetComponentInParent <ScrollRect>();
            }

            // cannot do anything without a parent ScrollRect -> return
            if (m_parentScroller == null)
            {
                return;
            }

            // forward the scroll event data to the parent
            m_parentScroller.OnScroll(data);
        }
Esempio n. 22
0
    public void OnScrollClampedShouldMoveContentAnchoredPosition(int scrollDeltaX, int scrollDeltaY, bool horizontal,
                                                                 bool vertical, int expectedPosX, int expectedPosY)
    {
        ScrollRect scrollRect  = m_PrefabRoot.GetComponentInChildren <ScrollRect>();
        Vector2    scrollDelta = new Vector2(scrollDeltaX, scrollDeltaY);
        var        expected    = new Vector2(expectedPosX, expectedPosY) * ScrollSensitivity;

        scrollRect.horizontal = horizontal;
        scrollRect.vertical   = vertical;

        scrollRect.OnScroll(new PointerEventData(m_PrefabRoot.GetComponentInChildren <EventSystem>())
        {
            scrollDelta = scrollDelta
        });

        Assert.AreEqual(expected, scrollRect.content.anchoredPosition);
    }
    public void RefreshFiles()
    {
        if (!Directory.Exists(m_currentPath))
        {
            return;
        }

        SelectedFile = null;

        for (int i = 0; i < activeItemCount; i++)
        {
            items[i].gameObject.SetActive(false);
        }

        activeItemCount = 0;

        if (!showHiddenFilesToggle.isOn)
        {
            ignoredFileAttributes |= FileAttributes.Hidden;
        }
        else
        {
            ignoredFileAttributes &= ~FileAttributes.Hidden;
        }

        string[] files;

        files = Directory.GetDirectories(m_currentPath);

        TryAddFiles(files, true);

        if (!m_folderSelectMode)
        {
            files = Directory.GetFiles(m_currentPath);

            TryAddFiles(files, false);
        }

        filesContainer.sizeDelta = new Vector2(0f, activeItemCount * itemHeight);

        // Prevent the case where the all the content stays offscreen after changing the search string
        filesScrollRect.OnScroll(nullPointerEventData);
    }
Esempio n. 24
0
        private void RefreshListView()
        {
            isListViewDirty = false;

            totalItemCount = 0;
            if (!m_isInSearchMode)
            {
                for (int i = sceneData.Count - 1; i >= 0; i--)
                {
                    totalItemCount += sceneData[i].Height;
                }
            }
            else
            {
                for (int i = searchSceneData.Count - 1; i >= 0; i--)
                {
                    totalItemCount += searchSceneData[i].Height;
                }
            }

            listView.UpdateList(false);
            scrollView.OnScroll(nullPointerEventData);
        }
Esempio n. 25
0
        private void Update()
        {
            if (dimensionsChangeCountdown > 0 && --dimensionsChangeCountdown == 0)
            {
                Vector2 size = ((RectTransform)transform).rect.size;
#if UNITY_EDITOR || (!UNITY_ANDROID && !UNITY_IOS)
                float dialogMaxHeight = size.y - dialogPadding.y;
#else
                float dialogTargetPaddingY = size.x < size.y ? dialogPadding.y : dialogPadding.x;                 // Swapping padding values on landscape orientation
                float dialogMaxHeight      = size.y - dialogTargetPaddingY;
#endif
                float dialogTargetHeight = scrollView.content.rect.height + contentPaddingY;
                dialog.sizeDelta = new Vector2(dialog.sizeDelta.x, dialogTargetHeight < dialogMaxHeight ? dialogTargetHeight : dialogMaxHeight);

                if (dialogCanvasGroup.alpha < 1f)
                {
                    dialogCanvasGroup.alpha = 1f;
                }

                // To prevent the scrollbar from overflowing when screen orientation changes
                scrollView.OnScroll(new PointerEventData(EventSystem.current));
            }
        }
Esempio n. 26
0
 // Make sure the scroll bar of the scroll rect is adjusted properly
 public void ValidateScrollPosition()
 {
     logItemsScrollRect.OnScroll(nullPointerEventData);
 }
Esempio n. 27
0
        public void RefreshFiles(bool pathChanged)
        {
            if (pathChanged)
            {
                allItems.Clear();

                try
                {
                    DirectoryInfo dir = new DirectoryInfo(m_currentPath);

                    FileSystemInfo[] items = dir.GetFileSystemInfos();
                    for (int i = 0; i < items.Length; i++)
                    {
                        allItems.Add(items[i]);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            validItems.Clear();

            SelectedFile = null;

            if (!showHiddenFilesToggle.isOn)
            {
                ignoredFileAttributes |= FileAttributes.Hidden;
            }
            else
            {
                ignoredFileAttributes &= ~FileAttributes.Hidden;
            }

            string searchStringLowercase = m_searchString.ToLower();

            for (int i = 0; i < allItems.Count; i++)
            {
                try
                {
                    FileSystemInfo item = allItems[i];

                    if ((item.Attributes & FileAttributes.Directory) == 0)
                    {
                        if (m_folderSelectMode)
                        {
                            continue;
                        }

                        FileInfo fileInfo = (FileInfo)item;
                        if ((fileInfo.Attributes & ignoredFileAttributes) != 0)
                        {
                            continue;
                        }

                        string extension = fileInfo.Extension.ToLower();
                        if (excludedExtensionsSet.Contains(extension))
                        {
                            continue;
                        }

                        HashSet <string> extensions = filters[filtersDropdown.value].extensions;
                        if (extensions != null && !extensions.Contains(extension))
                        {
                            continue;
                        }
                    }
                    else
                    {
                        DirectoryInfo directoryInfo = (DirectoryInfo)item;
                        if ((directoryInfo.Attributes & ignoredFileAttributes) != 0)
                        {
                            continue;
                        }
                    }

                    if (m_searchString.Length == 0 || item.Name.ToLower().Contains(searchStringLowercase))
                    {
                        validItems.Add(item);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            }

            listView.UpdateList();

            // Prevent the case where all the content stays offscreen after changing the search string
            filesScrollRect.OnScroll(nullPointerEventData);
        }
Esempio n. 28
0
 public void OnScroll(PointerEventData data)
 {
     MainScroll.OnScroll(data);
 }
 /// <summary>
 ///     Forward the scroll data
 /// </summary>
 /// <param name="data">Event data</param>
 public void OnScroll(BaseEventData data)
 {
     scrollRect.OnScroll((PointerEventData)data);
 }
Esempio n. 30
0
 public void OnScroll(PointerEventData eventData)
 {
     ItemScrollRect.OnScroll(eventData);
 }