Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity eventtrigger blocks scrollview

// Add below, it will do what Unity is absorbing with the event trigger. Place it onto the objects with an eventtrigger that is absorbing the scroll inputs on the scrollview.

public UnityEngine.UI.ScrollRect scrollView;
     // Start is called before the first frame update
     void Start()
     {
         EventTrigger trigger = GetComponent<EventTrigger>();
         EventTrigger.Entry entryBegin = new EventTrigger.Entry(), entryDrag = new EventTrigger.Entry(), entryEnd = new EventTrigger.Entry(), entrypotential = new EventTrigger.Entry()
             , entryScroll = new EventTrigger.Entry();
 
         entryBegin.eventID = EventTriggerType.BeginDrag;
         entryBegin.callback.AddListener((data) => { scrollView.OnBeginDrag((PointerEventData)data); });
         trigger.triggers.Add(entryBegin);
 
         entryDrag.eventID = EventTriggerType.Drag;
         entryDrag.callback.AddListener((data) => { scrollView.OnDrag((PointerEventData)data); });
         trigger.triggers.Add(entryDrag);
 
         entryEnd.eventID = EventTriggerType.EndDrag;
         entryEnd.callback.AddListener((data) => { scrollView.OnEndDrag((PointerEventData)data); });
         trigger.triggers.Add(entryEnd);
 
         entrypotential.eventID = EventTriggerType.InitializePotentialDrag;
         entrypotential.callback.AddListener((data) => { scrollView.OnInitializePotentialDrag((PointerEventData)data); });
         trigger.triggers.Add(entrypotential);
 
         entryScroll.eventID = EventTriggerType.Scroll;
         entryScroll.callback.AddListener((data) => { scrollView.OnScroll((PointerEventData)data); });
         trigger.triggers.Add(entryScroll);
     }
 }
Comment

PREVIOUS NEXT
Code Example
Csharp :: set windows theme in c# 
Csharp :: how to detect when a gameobject has exited a trigger c# 
Csharp :: wpf repository pattern query async with includes properties 
Csharp :: LINQ return list of unique values with counts 
Csharp :: C# Rev.ai transcription 
Csharp :: c# ClassMap 
Csharp :: c# silent execute exe 
Csharp :: c# convert timestamp to datetime 
Csharp :: c# remove exit icon 
Csharp :: C# Floating Point Literals 
Csharp :: shell32.dll c# example 
Csharp :: c# void with nullable List argument 
Csharp :: how to disable scale anti-aliasing in monogame 
Csharp :: How to truncate a decimal without rounding 
Csharp :: winforms lifecycle 
Csharp :: ASP.MVC display image from SqlServer 
Csharp :: AutoMapper Add Assemblies 
Csharp :: c# webrtc dll 
Csharp :: can you use unity for ftee 
Csharp :: C# Move Camera Over Terrain Using Touch Input In Unity 3D - Append To Camera 
Csharp :: pun 2 matchmaking custom room properties 
Csharp :: temp^late php table for mysql 
Csharp :: tempdata serializer cannot erorr 
Csharp :: bubble sort recursive c# 
Csharp :: C# Associativity of Operators 
Csharp :: c# date to julian YYJJJ date 
Csharp :: itext7 c# memorystream 
Csharp :: ef core totable 
Csharp :: internet connection sharing 
Csharp :: c# fastest way to find item in list 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =