Search code examples
inputscrollunity-game-enginemyo

How to access ScrollRect items and get it selected and clicked?


I am using Myo so my inputs are not the same as keypress and mouse.

I am trying to access items in the scroll UI Panel. Here is a snapshot of my Unity3D hierarchy.

https://i.sstatic.net/jk6yq.jpg

As you can see, I have

-StoreMenu
 -ScrollPanel
  -ScrollRect
   -ShopItems (list of items)

How can I possibly scroll and highlight the list of item. And on certain input gesture, get it selected ?

I'ved only managed this far:

                scrollpanel = GameObject.Find("ScrollPanel");
                scrollRect = scrollpanel.GetComponent<ScrollRect>();
                scrollRect.GetComponent<ScrollRect>();
                scrollRect.verticalNormalizedPosition = 0.5f;

I can get the scrollrect, move to certain position in the scroll but items are not highlighted.

Thanks in advance.


Solution

  • TRY THIS : http://docs.unity3d.com/462/Documentation/ScriptReference/EventSystems.EventSystem.SetSelectedGameObject.html

    This can be used to Set the object as selected