Search Unity

New UI Widgets

Discussion in 'Assets and Asset Store' started by ilih, Feb 11, 2015.

  1. dittytwo

    dittytwo

    Joined:
    Apr 30, 2015
    Posts:
    12
    Hi there found my recipt from the store and downloaded
    works a treat will be testing all the other widgets we are using to make sure nothing is broken but thank you for your quick response.
    cheers
    D2
     
  2. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih
    please make IsStopScrolling virtual in ListView Custom.
    Thanks
     
  3. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Ok
     
    jGate99 likes this.
  4. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    Great work with Paginator, works best as page indicators :)
     

    Attached Files:

    Last edited: Nov 27, 2016
  5. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih
    Can you please provide another component like SelectionHelper for a Toggle Button based on Switch?
    Switch let us provide color for both selected(normal, hover, down) and not selected states (normal, hover, down).
    but it also animate the object.

    What i need is this functionality without animation for a Toggle Button, so i can specify toggle color for both states selected and not selected.

    OR you can just another option in switch Direction None and then this can be used too for such task.

    Thanks
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Set Switch size equal to Mark size, and Animation Duration to 0, this way Switch will work without animation.
     
    jGate99 likes this.
  7. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih
    I get attached error with TileViewIcons with ScrollPaginator which doesnt have previous/next buttons but only active and default prefabs.

    This error happens when my tileview has lets say 45 items where each page show 10 items, so total 5 pages.
    If i go to page 3 and then assign remove items from its datasource it shows this error.

    I think you can solve this by resetting to page 1 whenever there is change in DataSource Count.

    Thanks
     

    Attached Files:

  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Fix:
    ScrollRectPaginator.cs, replace line 810
    old line:
    Code (CSharp):
    1. if (currentPage >= 0)
    new line:
    Code (CSharp):
    1. if ((currentPage >= 0) && (currentPage < DefaultPages.Count))
    And add following code at the end RecalculatePages():
    Code (CSharp):
    1.             if (currentPage >= Pages)
    2.             {
    3.                 GoToPage(Pages - 1);
    4.             }
     
    jGate99 likes this.
  9. super_star

    super_star

    Joined:
    Dec 20, 2016
    Posts:
    2
    Hi ilih,
    How can I enable the NodeToggle event for TreeView. I found that event on TreeViewCustom class but I don't know how to display it in inspector.
    Sorry, I'm too new with Unity. Thank you for your help!
     
  10. super_star

    super_star

    Joined:
    Dec 20, 2016
    Posts:
    2
    Sorry, I can using script to add that event. Thank you
     
  11. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Unfortunately Unity does not serialize field with nested generic class as type and this is why event not available in Inspector window, but you can add new event and attach to existing one, so new event will be available in Inspector.

    Code (CSharp):
    1.  
    2.     // create event class
    3.     [System.Serializable]
    4.     public class TreeViewNodeEvent : UnityEvent<TreeNode<TreeViewItem>> {
    5.     }
    6.  
    7.     public class TreeView : TreeViewCustom<TreeViewComponent,TreeViewItem> {
    8.  
    9.         // add new field for event
    10.         public TreeViewNodeEvent NodeToggleProxy = new TreeViewNodeEvent();
    11.  
    12.         // override Start()
    13.         bool isStarted = false;
    14.         public override void Start()
    15.         {
    16.             if (isStarted)
    17.             {
    18.                 return ;
    19.             }
    20.             isStarted = true;
    21.             base.Start();
    22.          
    23.             // invoke new event, when base event raised
    24.             NodeToggle.AddListener(NodeToggleProxy.Invoke);
    25.         }
     
    Last edited: Dec 20, 2016
    super_star likes this.
  12. darelf

    darelf

    Joined:
    Feb 9, 2015
    Posts:
    4
    hi tested your demo apk for android on my One plus One and it appears like this:
    gif uploader

    How you see i have a big blank space above controls.

    It is possible resolve this problem? It is possible adapt the height of controls to different androids?
     
  13. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Yes, it can be done few ways:
    • Using RectTransform anchors
    • Using layouts
    • Using LayoutSwitcher (part of New UI Widgets) to specify objects sizes, anchors, scale, etc for different resolutions
     
  14. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih
    Getting this error when i replace old UIWidget with Current Latest Beta.

    InvalidOperationException: out of sync
    System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,System.Collections.Generic.LinkedListNode`1[System.Int32]].VerifyState () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:912)
    System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,System.Collections.Generic.LinkedListNode`1[System.Int32]].MoveNext () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:835)
    System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[System.Int32,System.Collections.Generic.LinkedListNode`1[System.Int32]].MoveNext () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:1028)
    UIWidgets.LinkedHashSet`1[System.Int32].RemoveWhere (System.Predicate`1 match) (at Assets/UIWidgets/Standart Assets/Utilites/LinkedHashSet.cs:69)
    UIWidgets.ListViewBase.Start () (at Assets/UIWidgets/Standart Assets/ListView/ListViewBase.cs:236)
    UIWidgets.ListViewCustom`2[TComponent,TItem].Start () (at Assets/UIWidgets/Standart Assets/ListView/ListViewCustom.cs:497)
    UIWidgets.ListViewCustomHeight`2[TComponent,TItem].Awake () (at Assets/UIWidgets/Standart Assets/ListView/ListViewCustomHeight.cs:70)
     
  15. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Fix:
    Utilites/LinkedHashSet.cs, replace line 69 with following code:
    Code (CSharp):
    1.             var keys = new List<T>(dict.Keys);
    2.             foreach (var item in keys)
     
    jGate99 likes this.
  16. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih
    How can i use Range Slider for a Time Control
    where i ask user to provide convient time to call

    Slider has 9AM to 5pm Time
    and user can move two thumbs and select a timeframe which works for him.
     
  17. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Convert time to minutes and use minutes as values for slider.

    I added TimeRangeSlider with sample scene in 1.9.0b9 (Sample Assets / RangeSlider / TimeRangeSlider)
     
    jGate99 likes this.
  18. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    wow, Great work :D
     
  19. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    Can you please change it to 12 Hour clock, as currently im seeing 09:00 to 18:00

    Secondly add Label Support so 09:00 becomes 9:00 AM and 5 becomes 5:00 PM
     
  20. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Time range specified with following lines, so you need replace 9 and 18 to what hours you need.
    Code (CSharp):
    1.             slider.MinTime = new DateTime(2017, 1, 1, 9, 0, 0);
    2.             slider.MaxTime = new DateTime(2017, 1, 1, 18, 0, 0);
    Replace time format string to
    Code (CSharp):
    1. startText.text = start.ToString("hh:mm tt")
    Similar for endText.
     
    jGate99 likes this.
  21. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
  22. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
  23. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    yep we can but there should be a property("Owner") in ListItemBase so we can dispatch custom events form it .
    i m asking about official support ..
     
  24. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Please show what you want to achieve with this, I don't really understand why it can be needed.

    For now you can use event instead owner:
    Code (CSharp):
    1.  
    2. public class MyListView : ListViewCustom<MyComponent,MyItem>
    3. {
    4.         protected override void AddCallback(ListViewItem item, int index)
    5.         {
    6.             base.AddCallback(item, index);
    7.  
    8.             (item as MyComponent).MyEvent.AddListener(OnMyEvent);
    9.         }
    10.  
    11.         protected override void RemoveCallback(ListViewItem item, int index)
    12.         {
    13.             if (item!=null)
    14.             {
    15.                 (item as MyComponent).MyEvent.RemoveListener(OnMyEvent);
    16.             }
    17.  
    18.             base.RemoveCallback(item, index);
    19.         }
    20.  
    21.        void OnMyEvent()
    22.        {
    23.               // do something
    24.        }
    25. }
    26.  
    27. public class MyComponent : ListViewItem {
    28.        public UnityEvent MyEvent = new UnityEvent();
    29.  
    30.        void SomethingHappened()
    31.        {
    32.               MyEvent.Invoke();
    33.        }
    34. }
    If you want to send some data then you can use generic UnityEvent.
    Code (CSharp):
    1.  
    2.        void OnMyEvent(int index)
    3.        {
    4.               // do something
    5.        }
    6. }
    7.  
    8. public class MyUnityEvent : UnityEvent<int> {
    9. }
    10.  
    11. public class MyComponent : ListViewItem {
    12.        public MyUnityEvent MyEvent = new MyUnityEvent();
    13.  
    14.        void SomethingHappened()
    15.        {
    16.               MyEvent.Invoke(Index);
    17.        }
    18. }
    19.  
     
  25. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    right now i m making chat view , ListIItem has a Switch "Pin" you can pin your message from it.


    what i want is to have an event in Listview like this so it could be easily invoked in ListIem.

    Owner.OnPinChanged.Invoke(data);


    this is just an example , it could be used when ever Listitem want to communicate with ListView or MainScreen
     
  26. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Hi!
    as i stated earlier i m making chatwindow and now i need multiple ListItems in it ,
    it is usefull in
    LeftMessage
    RightMessage
    FileMessage
    Just Picture Message


    it would be Great if you Add multiple ListItems Support.
    Thanx
     
  27. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    This is possible with field for ListView:
    Code (CSharp):
    1. public class MyComponent : ListViewItem {
    2.     [SerializeField]
    3.     MyListView Owner;
    4.  
    5.     public void PinChanged()
    6.     {
    7.         Owner.OnPinChanged.Invoke(data);
    8.     }
    9. }
    Even if I add Owner field to DefaultItem component it will be require typecasting which make Owner field mostly useless.

    Please check "Sample Assets/TreeView/MultipleDefaultItems/*", It's sample for TreeView, but realization for ListView will be same.
    Selected DefaultItem depends of item class, but without problem can replaced with item field value.
     
  28. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Kindly can you give some Example ..?
     
  29. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    My mistake, it's should be "This is possible with field for DefaultItem component", not ListView.

    "Sample Assets / TileView / TileView" scene.
    TileView items have buttons + and - to duplicate and remove item from list, so DefaultItem component have Tiles field which is item owner.

    And code:
    Code (CSharp):
    1.         public TileViewSample Tiles;
    2.  
    3.         public TileViewItemSample Item;
    4.  
    5.         public void Duplicate()
    6.         {
    7.             Tiles.DataSource.Add(Item);
    8.         }
    9.  
    10.         public void Remove()
    11.         {
    12.             Tiles.DataSource.RemoveAt(Index);
    13.         }
     
  30. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
  31. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
  32. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
  33. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Fix:
    RangeSliderBase.cs
    Replace line 11:
    Code (CSharp):
    1.     public abstract class RangeSliderBase<T> : UIBehaviour, IPointerClickHandler
    And add following function:
    Code (CSharp):
    1.         protected override void OnRectTransformDimensionsChange()
    2.         {
    3.             UpdateMinHandle();
    4.             UpdateMaxHandle();
    5.             UpdateFill();
    6.         }
     
    jGate99 likes this.
  34. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih, Fixed and Thanks
     
  35. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Sorry i can't understand... Can you make Sample List in your Demo Scene With More then one ListItem Like chat , using custom ListItems.
     
  36. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Please check attached sample.
    Changes:
    • ChatView.cs, added event:
      Code (CSharp):
      1.     public class ChatView : ListViewCustomHeight<ChatLineComponent,ChatLine> {
      2.         [SerializeField]
      3.         public UnityEvent MyEvent;
    • ChatLineComponent.cs, added Chat field and function to invoke event:
      Code (CSharp):
      1.     public class ChatLineComponent : ListViewItem {
      2.         [SerializeField]
      3.         public ChatView Chat;
      4.  
      5.         public void ChatEventInvoke()
      6.         {
      7.             Chat.MyEvent.Invoke();
      8.             Debug.Log("MyEvent.Invoke()");
      9.         }
    • Inspector window, ChatView.DefaultItem, added link to ChatView gameobject in Chat field, and OnClick event added ChatEventInvoke() call
     

    Attached Files:

  37. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    1-
    Thanx for this Chatview Event setup , i have already followed you instructions and made thing like this .
    but i was talking about example scene for multiple ListItems ..just like you have here but chat view with multiple ListItems.

    2-
    as i have told you before i m making chat view , here user can pin message . To pin message
    i m using "Switch" of you ,
    attached a listener to Switch , which request to server this message is pined or not.

    but problem is in SetData() when ever we assign value to switch , it trigger event ,

    i have made temp solution for it

    RemoveEvents();
    PinSwitch.IsOn = (data as VOGroupMessage).IsPinned;
    AddEvents();

    which is not good.

    potential solution:-
    A new Property on

    PinSwitch.IsOnWithOutEvent

    so we can assign values to Controls with out triggering their listeners.
     
  38. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Not really understand, can you explain with some example?

    I can add Switch.SetStatus() function for it, but maybe better check if value changed in listener call
    Code (CSharp):
    1.         protected VOGroupMessage Item;
    2.  
    3.         public void SetData(...)
    4.         {
    5.             Item = data as VOGroupMessage;
    6.  
    7.             PinSwitch.IsOn = Item.IsPinned;
    8.         }
    9.  
    10.         void SwitchListener(bool value)
    11.         {
    12.             if (Item.IsPinned==value)//if not changed
    13.             {
    14.                 return ;
    15.             }
    16.             // otherwise send request to server
    17.         }
     
  39. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
  40. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
  41. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    Thanks

    Another Problem is i want to add a second button to Accordion Header (Or multiple small buttons, like remove accordion item, add new item etc) So i moved Selectable to Header's child, also make a 2nd mini button and put it over header but now header is not clickable anymore. Please advise.

    What'd happen is if i click black area then header open/close, if i click on button then something else happens, i can put anything at that area, dropdown, button input field anything so it should be generic.
    http://www.giphy.com/gifs/l3q2HF7zxiMH3j9vy
     
  42. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Add Image component or any other Graphic component, without it click (or any other ui events) does not work.
     
  43. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    Another problem is If my Accordion Control has 1000 height, and there are 4 accordion panels and each header takes 50 height and then 4 headers = 200 and remaining space is 800.

    So when either 1 panel is open or multiple , all the panel content takes that space (like fit to height).
    This way each panel content will have its own scrollbar and thats what i need.

    Thanks
     
  44. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    I tried giving flexiable height to 999 to all the panel content but they are still 100 when play mode.
     
  45. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    1. Add LayoutElement to Header gameobjects, settings MinHeight=50, PreferredHeigth = 50, Flexible Height = 0
    2. Add LayoutElement to Panels (Content gameobjects) without settings
    3. Accordion.ResizeMethod = Flexible
    4. Accordion.EasyLayout.ChildrenHeight = Fit Container
     
  46. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    It doesnt seem to work. Can you please provide sample?
     
  47. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    @ilih

    2nd Problem, List control inside an Accordion doesnt seem to take HighlightColoring Effect, If i move this List outside of Accordion's Content then highlight comes back.

    Please advise
     
  48. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,409
    Sample scene attached.
    ListView highlight works fine, I cannot reproduce such effect.
     

    Attached Files:

  49. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    Here is Chat List , Two users are communicating , both has different ListItems



    i just want to skip this step. that's why i m asking about "Switch.SetStatus()"
     
  50. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,941
    So it only works when we set items again? It doesnt work autoamtically?


    As for ListView Heightlight, your ListViewHeight works but not mine which is extended from CustomListHeight. I also see ColoringHighliht function gets triggered but colors doesnt change at all. What could i be doing worng?
     
    Last edited: Jan 14, 2017