Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by veboys · Aug 10, 2015 at 09:29 AM · unity 5ui

the new UI system: scrollrect can not scroll when it's content have a PointerDown event

Hi unity people..I use the new UI system to make a ScrollViewer, everything works fine until I add PointerDown event to the content gameObjects of ScrollRect. I can't scroll when I click on the gameObject which have PointerDown event.

any one know how to fix this?

update: I find out it's EventTrigger component on the content gameObject makes the scroll function not work. but I have to use the PointerDown event, so the EventTrigger component is necessary.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dasm30 · Aug 30, 2015 at 09:49 PM 0
Share

same issue here..

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by veboys · Aug 31, 2015 at 12:38 PM

I solved this myself. "NOTE: Attaching this component to a GameObject will make that object intercept ALL events, and no event bubbling will occur from this object!", this is a note about EventTrigger component from the unity manual.

so I created a custom component and implement the IPointerDown interface to replace the EventTrigger component.

problem solved!

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dasm30 · Aug 31, 2015 at 01:36 PM 0
Share

I had to do the same, just created my own script that implements multiple interfaces except for the IDragHandler which seems to be the one stopping the scroll rect from working again

avatar image veboys · Sep 05, 2015 at 09:30 AM 0
Share

@dasm30 you could delete a interface each time to find out which one is the 'cri$$anonymous$$al'

avatar image lolzrofl · Sep 05, 2015 at 04:41 PM 0
Share

Would you $$anonymous$$d posting a pastebin with your implementation? :)

avatar image
2

Answer by dasm30 · Sep 06, 2015 at 12:31 PM

@lolzrofl I'm posting my code, you just need to add any other interface you may need, and use the internal variables to subscribe to the events. The script need to be added to the object in which you want the events to be called. Please up vote my answer if it helped you.

 //By: Daniel Soto
 //4dsoto@gmail.com
 using UnityEngine;
 using System.Collections;
 using UnityEngine.EventSystems;
 using UnityEngine.Events;
 
 
 namespace LSCore.Events {
 
     public class EventTriggers : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler/*,
     IBeginDragHandler, IDragHandler, IEndDragHandler*/ {
 
         internal UnityAction<BaseEventData> m_OnPointerDown;
         internal UnityAction<BaseEventData> m_OnPointerUp;
         internal UnityAction<BaseEventData> m_OnPointerEnter;
         internal UnityAction<BaseEventData> m_OnPointerExit;
         internal UnityAction<BaseEventData> m_OnBeginDrag;
         internal UnityAction<BaseEventData> m_OnDrag;
         internal UnityAction<BaseEventData> m_OnEndDrag;
 
 
         
         public void OnPointerDown (PointerEventData eventData) {
             // Do action
             if( m_OnPointerDown != null )
             {
                 m_OnPointerDown( eventData );
             }
         }
         
         public void OnPointerUp (PointerEventData eventData) {
             // Do action
             if( m_OnPointerUp != null )
             {
                 m_OnPointerUp( eventData );
             }
         }
 
         public void OnPointerEnter (PointerEventData eventData) {
             // Do action
             if( m_OnPointerEnter != null )
             {
                 m_OnPointerEnter( eventData );
             }
         }
         
         public void OnPointerExit (PointerEventData eventData) {
             // Do action
             if( m_OnPointerExit != null )
             {
                 m_OnPointerExit( eventData );
             }
         }
 
         /*public void OnBeginDrag (PointerEventData eventData) {
             // Do action
             if( m_OnBeginDrag != null )
             {
                 m_OnBeginDrag( eventData );
             }
         }
 
         public void OnDrag (PointerEventData eventData) {
             // Do action
             if( m_OnDrag != null )
             {
                 m_OnDrag( eventData );
             }
         }
 
         public void OnEndDrag (PointerEventData eventData) {
             // Do action
             if( m_OnEndDrag != null )
             {
                 m_OnEndDrag( eventData );
             }
         }*/
         
     }
 
 }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Disable on screen keyboard for mobile phones 1 Answer

UI Text In Seconds 2 Answers

Unity 5: How to display bird eye view layout of a 3D scene with UI component overlay on screen? 1 Answer

SetActive true not working on UI object 2 Answers

Stacked UI Panels do not position as expected 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges