ScrollList Mouse Wheel Scroller

This is the place to post add-on scripts you have written that use EZ GUI. Please remember only to post your add-on content and not the original EZ GUI scripts.
Forum rules
Only post your own add-on content and not any of the original EZ GUI scripts.

ScrollList Mouse Wheel Scroller

Postby tgdwire » Mon Oct 17, 2011 8:58 pm

So this will be the first thing I've put out here to the anbsoft forums as far as code goes. It's a scroll list scroller based on snapped item. You can give it a duration for snapping to whichever item in the inspector. It's pretty basic as I was going from a specific implementation for one list i had to a generic one for a couple of lists we have now. The code itself is pretty straightforward and it'd be cool to see something similar implemented into ezgui later on. Until then this may help someone out. Just attach it to the game object youd like to have scroll wheel control over. There's probably better ways to do this but this is it:
Code: Select all
using UnityEngine;
using System.Collections;

public class ListScroller : MonoBehaviour
{
    private int SnappedItemIndex = 0;
    private UIScrollList list;
    public float ScrollTime = 0.2f;

    // Use this for initialization
    void Start()
    {
        list = GetComponent<UIScrollList>();
        list.snap = true;
        list.AddItemSnappedDelegate(ItemDelegate);
    }

    //This is in case the snapped index changes elsewhere.
    void ItemDelegate(IUIListObject obj)
    {
        SnappedItemIndex = obj.Index;
    }

    //Preprocessor guards against taking up cpu cycles on devices that wouldn't have mice.
    //Unity editor included so you don't have to switch build targets to test it.
#if !UNITY_ANDROID && !UNITY_IPHONE || UNITY_EDITOR

    void Update()
    {
        float WheelDelta = Input.GetAxis("Mouse ScrollWheel");
        if (WheelDelta != 0 && IsOverList())
        {
            if (list.SnappedItem != null)
            {
                if (WheelDelta > 0 && SnappedItemIndex > 0)
                    list.ScrollToItem(list.SnappedItem.Index - 1, ScrollTime);
                else if (WheelDelta < 0 && list.Count > SnappedItemIndex + 1)
                    list.ScrollToItem(list.SnappedItem.Index + 1, ScrollTime);
            }
        }
    }

    bool IsOverList()
    {
        try
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            Physics.Raycast(ray, out hit, Mathf.Infinity);

            if (hit.transform.gameObject == gameObject)
                return true;

            for (int i = 0; i < list.Count; i++)
            {
                if (hit.transform.gameObject == list.GetItem(i).gameObject)
                    return true;
            }
            return false;
        }
        catch (System.Exception ex)
        {
            Debug.LogError(ex.Message);
            Debug.LogError(ex.StackTrace);
            return false;
        }
    }
#endif
}


edit: Guarded against a few null exceptions.
Last edited by tgdwire on Thu Oct 20, 2011 4:44 pm, edited 3 times in total.
tgdwire
 
Posts: 4
Joined: Mon Apr 18, 2011 5:19 pm

Re: ScrollList Mouse Wheel Scroller

Postby Brady » Wed Oct 19, 2011 12:10 am

Thanks for sharing. Could you explain in more detail what this does regarding the scroll wheel? Scrolling a scroll list with a mouse wheel is currently implemented in the current version, but it sounds like you're doing something slightly different.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: ScrollList Mouse Wheel Scroller

Postby tgdwire » Thu Oct 20, 2011 3:43 pm

This is for scrolling between items and snapping to them explicitly as it goes. This way you can also use the different easing types with the scrolling as well. Just has a smooth feel to it. This might already be in, I just hadn't seen it. One thing I didn't guard against here was a null item in the next index or previous index, so I'll update the code with that while I'm here.
tgdwire
 
Posts: 4
Joined: Mon Apr 18, 2011 5:19 pm

Re: ScrollList Mouse Wheel Scroller

Postby Brady » Thu Oct 20, 2011 7:24 pm

Cool, that sounds nice.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

Re: ScrollList Mouse Wheel Scroller

Postby MartinSchultz » Tue Nov 22, 2011 12:41 pm

I'd be interested how to achieve mouse wheel scrolling in an UIScrollList. So far I can only use click-and-drag scrolling, but not everyone might feel this intuitive so I'd like to add mouse wheel scrolling too. What is necessary to add it?
MartinSchultz
 
Posts: 16
Joined: Mon Feb 21, 2011 8:51 pm

Re: ScrollList Mouse Wheel Scroller

Postby Brady » Wed Nov 23, 2011 9:39 pm

It is built-in to the latest versions. You don't need to do anything more. Just make sure your Scroll Wheel Factor setting isn't set to 0 and it should respond to the scroll wheel.
Brady
 
Posts: 5361
Joined: Tue Jul 06, 2010 11:33 pm

jlgg

Postby jlgg » Sat Apr 22, 2017 7:59 am

burberry australia
nike huarache
coach factory outlet
pandora rings
timberland boots
prada bags
kate spade handbags
michael kors australia
pandora bracelets
ray ban prescription sunglasses
coach outlet
china factory sale
pandora charms
canada goose jacket
louis vuitton australia
michael kors online
Ralph Lauren Polo
burberry scarf
michael kors wallet
pandora rings
Chanel Outlet
michael kors
prada factory outlet online
michael kors uk
adidas shoes
coach factory outlet
timberland uk
ray ban polarized
prada handbags
prada official site
kate spade
michael kors bags
sunglasses hut
hermes bag
baseball jerseys
michael kors outlet
pandora rings sale
michael kors purses
michael kors outlet
nike jordan shoes
burberry australia
landing gear
coach australia
kate spade outlet online
michael kors outlet
michael kors outlet
burberry online
coach usa
coach outlet online
abercrombie and fitch
nike outlet
kate spade canada
nike air max
prada outlet prices
louis vuitton outlet
michael kors canada
kate spade
coach outlet
moncler jacket
Kevin Durant Shoes
yeezy boost 350
air jordan retro
nike air huarache
abercrombie outlet
coach outlet store
kate spade bags
michael kors outlet
prada outlet
michael kors
pandora rings
nike outlet
moncler outlet
burberry outlet canada
cheap coach purse
michael kors outlet
prada factory outlet online
Mizuno Running Shoes
salomon shoes
huarache nike
pandora australia
coach factory outlet
prada outlet
michael kors outlet
air jordan shoes
coach outlet
coach bags
coach outlet
pandora australia
Yeezy Boost 350
brand sunglasses
oakley sunglasses
ray ban glasses
pandora bracelet
michael kors outlet
ray ban sunglasses
ray ban outlet
burberry canada
Burberry outlet online
yeezy boost 350
asics shoes Australia
prada outlet
Mizuno Wave
clk benz
michael kors outlet bags
michael kors outlet online
paul smith uk
canada goose sale online
beats by dre
ugg australia
prada handbags
coach factory
coach online
chanel australia
nike jordan
coach outlet
polo outlet online
longchamp outlet
asics Australia
burberry outlet online
burberry outlet
Nike Air Jordan
cheap basketball shoes
nike lebron james
Free Run
nike store
moncler coats
KD 8 shoes
polo outlet
Nike Hyperdunk 2015
shoes sale
mlb.com
rayban aviator
coach outlet
kate spade outlet
asics shoes
coach australia
michael kors jet set tote
pandora charms sale
burberry scarfs
prada outlet online
CHanel Factory Outlet
authentic prada outlet online
moncler jacket
nike lebron shoes
Mizuno Shop
coach carter
moncler jacket mens
ate spade handbags
pandora jewelry
pandora charms
prada outlet
moncler clothing
pandora bracelet
canada goose sale
snow boots
Pandora Charm
burberry outlet
abercrombie fitch
prada bags
mlb shop
Hugo Boss Outlet
jimmy choo australia
kate spade outlet
ugg boots
Oakley Outlet
prada outlet online
ray ban aviator
kate spade outlet
michael kors
kate spade bags
abercrombie outlet
nike shoes
Mizuno Shoes
baseball jerseys
coach purses
pandora necklaces
mens sunglasses
coach outlet
sunglasses sm
coach outlet
tiffany uk
pandora.com
jordan retro shoes
major league baseball
coach outlet
nfl shop
ugg uk
Hyperdunk 2016
nike free run
nike shoes australia
pandora rings
pandora charms
ugg slippers
pandora jewelry
nike com
prada outlet online
burberry outlet
huaraches
nike jordan shoes
prada purses
Jordan Retro
pandora charms
oakley frogskins
abercrombie us
coach bag
ray ban clubmaster
Hermes Outlet
michael kors bags
pandora rings
burberry outlet canada
Nike KD 8
official prada site
pandora rings jewelry
mk outlet
Nike Air Max
michael kors outlet
authentic prada outlet online
coach outlet
prada outlet online
pandora rings
yeezy boost 350 shoes
Coach Outlet Store
michael kors totes
pandora australia
burberry online
kate spade outlet
prada outlet online
coach factory outlet
basketball jerseys
coach diaper bag
coach factory outlet online
Abercrombie Fitch
oakley frogskins sunglasses
michael kors handbags
oakley sunglasses
burberry outlet
louis vuitton outlet
Mizuno Shop Japan
air jordan shoes
kate spade outlet online
Prada bags
nike shox shoes
louis vuitton outlet
wholesale
kate spade bags outlet
prada outlet online
pandora princess ring
Hugo Boss Store
moncler uk
Michael Kors Canada
nike huarache shoes
hockey jerseys
burberry outlet
moncler us
ray ban online
michael kors handbags outlet
ray ban sunglasses
michael kors outlet
china wholesale
moncler outlet
tiffany co
coach handbags
abercrombie outlet
piumini moncler replica
michael kors outlet
kate spade black friday
ralph lauren australia
pandora australia
burberry purse
michael kors outlet
coach
mcm outlet online
nike basketball shoes
michael kors outlet
basketball jerseys
authentic prada handbags outlet
coach bags
ray ban sunglasses
ray-ban sunglasses
michael kors italy
ralph lauren
mlb shop
Billat
pandora rings
paul smith
ray-ban sunglasses
burberry canada
Prada Factory Outlet
prada us
tiffany co
top sunglasses
bercrombie Nederland
nike australia
michael kors outlet
moncler sale
Prada Outlet
sunglasses outlet
Michael Kors Outlet
ray-ban sunglasses
coach outlet online
prada outlet
kate spade outlet
michael kors outlet
football jerseys
MIZUNO Shop US
canada goose jacket
Adidas Yeezy Boost 350
pandora uk
pandora rings
michael kors purses outlet
burberry
salomon hiking shoes
abercrombie outlet us
nfl jerseys
pandora charms sale
michael kors outlet online
shoes online sale
Yeezy 350
michael kors outlet
football jerseys
pandora charms uk
prada glasses
coach australia
michael kors handbags
landinggear
prada bags
huaraches shoes
canada goose outlet
adidas australia
prada sale
michael kors outlet
cheap ray ban sunglasses
flash sunglasses
polo online
Nike Jordans
prada factory outlet online
coach outlet
pandora ring
burberry outlet online
abercrombie paris
Longchamp Outlet
michael kors outlet
Oakley Holbrook sunglasses
beats headphones
pandora charms
prada online
Coach outlet online
prada outlet online
nike shoes
coach outlet
abercrombie us
michael kors outlet
michael kors purses
kate spade black friday
coach shoes
tiffany and co
michael kors us
michael kors
veronique billat
burberry scarf
Nike Jordan Shoes
ups tracking
véronique Billat
nike australia
moncler down jackets
mcm factory outlet
mcm outlet
abercrombie outlet
Coach Outlet Online
ray ban new wayfarer
pandora charms
kate spade outlet
cheap moncler jacket
kate spade
adidas australia
michael kors outlet
Nike Hyperdunk Shoes
official prada site
mk bags
Kate Spade Australia
coach sunglasses for women
coach outlet
landing gears
coach sunglasses
pandora charms black friday
ugg australia
Ray Ban Outlet
michael kors bags
pandora bracelet
michael kors tote
michael kors handbags
sunglasses hut
pandora charms sale online
burberry us
Nike Air Jordan
ray ban outlet
adidas yeezy boost 350
Coach Outlet
ray ban prescription glasses
michael kors uk
Chanel bags Outlet
chanel
longchamp outlet
ray ban sunglasses
louboutin shoes
Cheap Ray Ban
abercrombie and fitch
Nike Free
Coach Sunglasses Outlet
prada bags outlet
Jordan retro
baseball jerseys
michael kors purses on sale
nike id
prada bag
abercrombie and fitch
abercrombie & fitch
shoes online
paul smith sale
michael kors black friday
ray ban eyeglasses
prada sunglasses
oakley australia
coach outlet online
coach purse
coach outlet online
burberry scarf
prada bags on sale
abercrombie outlet
moncler jacket
Canada Goose Outlet
Michael Kors Outlet
Ralph Lauren
michael kors outlet
lebron james shoes
michael kors outlet
ray ban wayfarer
michael kors tote
pandora jewelry
oakley sunglasses
beats studio
michael kors bags outlet
Hugo Boss Online
burberry outlet
nike jordan shoes
Pandora bracelet
prada outlet online
michael kors outlet online
Oakley Holbrook
michael kors outlet
louis vuitton uk
oakley outlet
prada factory outlet
louis vuitton outlet
jordan shoes
Basketball shoes
coach outlet
pandora uk
pandora necklace charms
michael kors outlet
pandora charms sale clearance
official michael kors
michael kors outlet
mlb store
chanel bag
coach outlet
pandora necklace
coach handbags
michael kors factory outlet
yeezy boost 350
Jordan Retro Shoes
moncler mens jackets
moncler outlet
nike shox
louis vuitton factory outlet
prada handbags
mk handbags
prada outlet
jlgg4.22
jlgg
 
Posts: 55
Joined: Thu Jul 28, 2016 9:25 am




Return to EZ GUI Add-ons

Who is online

Users browsing this forum: No registered users and 3 guests