Search Unity

New UI Widgets

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

  1. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,939
    @ilih
    TMPro based UIWidget update is missing AutoComplete again.
    im also getting errors such as

    Update 2
    Assets/UIWidgets-TMProSupport/Standart Assets/ListView/ListViewIconsItemComponentTMPro.cs(29,4): error CS0103: The name `item' does not exist in the current context

    Update 3
    Looks like 1.9.2b1 doesnt have its related TMPro package, i replaced TMPro with and old release which is now showing errors like this
    Code (CSharp):
    1. IndexOutOfRangeException: Array index is out of range.
    2. TMPro.TMP_Text.StringToCharArray (System.String sourceText, System.Int32[]& charBuffer) (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:2306)
    3. TMPro.TMP_Text.ParseInputText () (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:1699)
    4. TMPro.TMP_Text.GetPreferredWidth () (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:3424)
    5. TMPro.TMP_Text.get_preferredWidth () (at Assets/TextMesh Pro/Scripts/TMP_Text.cs:1271)
    6. EasyLayout.LayoutElementInfo.<GetPreferredWidth>m__0 (ILayoutElement x) (at Assets/UIWidgets/Standart Assets/EasyLayout/LayoutElementInfo.cs:248)
    7. EasyLayout.LayoutElementInfo.GetLayoutParameter (UnityEngine.RectTransform rect, System.Func`2 func) (at Assets/UIWidgets/Standart Assets/EasyLayout/LayoutElementInfo.cs:370)
    8. EasyLayout.LayoutElementInfo.GetPreferredWidth (UnityEngine.RectTransform rect) (at Assets/UIWidgets/Standart Assets/EasyLayout/LayoutElementInfo.cs:248)
    9. EasyLayout.LayoutElementInfo..ctor (UnityEngine.RectTransform rectTransform, EasyLayout.EasyLayoutResizer resizer, EasyLayout.EasyLayout layout) (at Assets/UIWidgets/Standart Assets/EasyLayout/LayoutElementInfo.cs:178)
    10. EasyLayout.EasyLayout.CreateLayoutElementInfo (UnityEngine.RectTransform rect) (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1124)
    11. System.Collections.Generic.List`1[UnityEngine.RectTransform].ConvertAll[LayoutElementInfo] (System.Converter`2 converter) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:185)
    12. EasyLayout.EasyLayoutExtensions.Convert[RectTransform,LayoutElementInfo] (System.Collections.Generic.List`1 input, System.Converter`2 converter) (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayoutExtensions.cs:46)
    13. EasyLayout.EasyLayout.GetUIElements () (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1110)
    14. EasyLayout.EasyLayout.GroupUIElements () (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1192)
    15. EasyLayout.EasyLayout.CalculateLayoutSize () (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1019)
    16. EasyLayout.EasyLayout.CalculateLayoutInputHorizontal () (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:934)
    17. EasyLayout.EasyLayout.UpdateLayout () (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1037)
    18. EasyLayout.EasyLayout.OnValidate () (at Assets/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1238)
    19.  
     
    Last edited: Jun 24, 2017
    platformshliilh likes this.
  2. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Please check 1.9.2b3, added ScaleDownAndPush animation for Sidebar

    I updated TMPro support packages to 1.9.2b3 with widgets for Autocomplete, FileDialog, FolderDialog, Calendar and DatePicker.
     
    jGate99 likes this.
  3. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,939
    @ilih,
    I'm getting File Access Permission on Android even though im not using any file access. IS this due to your updated package with File support in it? If so can you please move all file related stuff in a folder which i can delete it without interrupting other Widgets?
     
  4. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    I dont think so.
    You can check android demo - it request permission only for internet connection.
    Maybe you set android build settings ''Write permission" to "External"?
    What Unity version you use for android builds?
     
  5. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,939
    Then something else is causing it, Using 5.6.1p4 with Android Target SDK to 25 (Latest)
     
  6. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Development build?
     
  7. Mazak

    Mazak

    Joined:
    Mar 24, 2013
    Posts:
    226
    Using Version 2017.1.0F2 I am getting 26 warnings when I make a build & only when making builds:

    Code (CSharp):
    1. SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
    2. UnityEngine.RectTransform:SetSizeWithCurrentAnchors(Axis, Single)
    3. EasyLayout.LayoutElementInfo:ApplyResize() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/LayoutElementInfo.cs:217)
    4. EasyLayout.EasyLayout:<GroupUIElements>m__0(LayoutElementInfo) (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1219)
    5. System.Collections.Generic.List`1:ForEach(Action`1)
    6. EasyLayout.EasyLayout:GroupUIElements() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1219)
    7. EasyLayout.EasyLayout:CalculateLayoutSize() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1019)
    8. EasyLayout.EasyLayout:CalculateLayoutInputHorizontal() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:934)
    9. EasyLayout.EasyLayout:UpdateLayout() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1037)
    10. EasyLayout.EasyLayout:OnValidate() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1238)
    11. UnityEditor.HostView:OnGUI()
    I also get:
    Code (CSharp):
    1. SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
    2. UnityEngine.Transform:set_localPosition(Vector3)
    3. EasyLayout.EasyLayoutPositioner:SetPositionsVertical(List`1) (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayoutPositioner.cs:274)
    4. EasyLayout.EasyLayoutPositioner:SetPositions(List`1) (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayoutPositioner.cs:209)
    5. EasyLayout.EasyLayout:RepositionUIElements() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1029)
    6. EasyLayout.EasyLayout:SetLayoutHorizontal() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:917)
    7. EasyLayout.EasyLayout:UpdateLayout() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1038)
    8. EasyLayout.EasyLayout:OnValidate() (at Assets/3rdParty/UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs:1238)
    9. UnityEditor.HostView:OnGUI()
    10.  
     
  8. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Fix:
    UIWidgets/Standart Assets/EasyLayout/EasyLayout.cs
    Replace line 1238 on "SetDirty();"
    Old code:
    Code (CSharp):
    1.         protected override void OnValidate()
    2.         {
    3.             UpdateLayout();
    4.         }
    5.  
    New code:
    Code (CSharp):
    1.         protected override void OnValidate()
    2.         {
    3.             SetDirty();
    4.         }
    5.  
     
    Mazak likes this.
  9. Mazak

    Mazak

    Joined:
    Mar 24, 2013
    Posts:
    226
    Fixed

    Thank you
     
  10. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    @ilih Found a bug with the color picker. If you use Gamma color space then it shows up correctly. But if you use Linear color space, the hue palette shows up wrong. Tested in both 5.5.1f1 and 5.6.1f1.

    Gamma:
    Gamma Color Space.PNG

    Linear:
    Linear Color Space.PNG
     
    Last edited: Jul 29, 2017
  11. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Thanks, I fixed it.
    Please download and import UIWidgets 1.9.2b4 Shaders fix or full 1.9.2b4 unitypackage for Unity 5 or later.
     
    GibTreaty and hopeful like this.
  12. GibTreaty

    GibTreaty

    Joined:
    Aug 25, 2010
    Posts:
    792
    Woot woot! Thanks!
     
  13. PeterShoferistov

    PeterShoferistov

    Joined:
    Sep 22, 2013
    Posts:
    59
    First of all, thanks for making a decent asset pack and keeping it alive!

    It looks like there is a bug in validation method. If I'll change the validation type for Spinner widget to "OnEndInput", it will work just once.

    To reproduce the bug:
    1. Set the range on spinner to, let's say, 1-100
    2. Enter any value in range 1-100, for example 50. Works fine.
    3. Reselect the input field and type a new value, for example 9999. Value changed to 100. Works fine.
    4. Reselect the input field again and type another value, for example 1111. Value doesn't changed. Here is the bug.
    Now this field won't validate at all, unless user inputs another value in range 1-100, then it will validate fine for once and will be broken again.

    Here is a captured video:
    https://1drv.ms/v/s!AuyHy4WnaMnUg-dvZxKt1eEpjPn7zA

    I don't want to edit your scripts so I wrote my own separate validator and binded it's method to OnEndEditString, but it would be nice to get some sort of fix by the author.


    UPD.
    Here is another bug: I can't change spinner's value from the keyboard if it's min and max ranges are set from -10 (any negative value) to 0. Because of that I have to delete value completely with backspace before entering the new one. Validation type is "OnEndInput"
     
    Last edited: Aug 14, 2017
  14. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Thanks.
    Please check 1.9.2b6
    I fixed first bug and made some changes with second: validation did not work correctly with selection, now it should work in all cases except typing before minus sign.
     
    PeterShoferistov likes this.
  15. PeterShoferistov

    PeterShoferistov

    Joined:
    Sep 22, 2013
    Posts:
    59
    Last edited: Aug 14, 2017
  16. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    PeterShoferistov likes this.
  17. PeterShoferistov

    PeterShoferistov

    Joined:
    Sep 22, 2013
    Posts:
    59
    Thanks for a quick response, works like a charm!
     
  18. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Is there a way to improve the FPS for the color picker ? Each time when a new color is selected, the FPS drops considerably. On Mobile, it's not usable at all.

    Cheers
     
  19. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    I made some improvements in 1.9.2b9. Please try it.
    If fps still drops can you tell what palette mode you use?
     
    jGate99 likes this.
  20. Duende

    Duende

    Joined:
    Oct 11, 2014
    Posts:
    200
    Hi! Is this compatible with TextMesh Pro?
     
  21. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Yes, but for now it's available only for beta versions.
     
  22. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    1,939
    @ilih,
    Currently AutoComplete component loads data right away if we type something, however im loading data from a local sqlite which get stuck for few seconds (due to complex query) every time i type, so if you can add a delay so i make request to sql when user hs not type for 1 second.
    Thanks
     
  23. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Please check "Sample Assets/Autocomplete/AutocompleteRemote.cs", it's load data with delay from web, you just need to replace web request on sqlite query.
    You can use ApplyFilter() as it is and make some changes in LoadData():
    Code (CSharp):
    1.         protected virtual IEnumerator LoadData(string search)
    2.         {
    3.             yield return new WaitForSeconds(Delay);//here you set delay in seconds
    4.  
    5.             // here should be sqlite query
    6.             DisplayListView.DataSource = GetDataFromSqlite(search);
    7.  
    8.             if (DisplayListView.DataSource.Count > 0)
    9.             {
    10.                 ShowOptions();
    11.                 DisplayListView.SelectedIndex = 0;
    12.             }
    13.             else
    14.             {
    15.                 HideOptions();
    16.             }
    17.         }
     
  24. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    178
    HI!

    I also need This feature. i m using This Dictionary for Autocomplete. it has 479k English words.
    Now the thing is AutoComplete slow down and hold UI while when i'm Typing on it, or even pressing left,right.
    its querying data on each keystroke.which is slowing down.

    It could be optimized. you can introduce a delay like "autoCompleteDelay".
    I had make a control in past here its code.

    Code (CSharp):
    1. private void ControlValueChange(string text)
    2.         {
    3.             if (autoCompleteDelay > 0)
    4.             {
    5.                 CancelInvoke("ControlValueChanged");
    6.                 Invoke("ControlValueChanged", autoCompleteDelay);
    7.             }
    8.             else
    9.             {
    10.                 ControlValueChanged();
    11.             }
    12.         }
    please add autoCompleteDelay in AutoComplete.

    Thanks :)
     
  25. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Please check 1.9.2b10
    Added MinLength, SearchDelay and UnscaledTime options for Autocomplete.
     
  26. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Question: In the JRPG shop, can you extend this so that one can order the rows by clicking on the header buttons.

    Shop Items
    Price
    Available
    Count


    Cheers.
     
  27. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Added, please update to 1.9.2b11

    Or you can replace UIWidgets/Sample Assets/Shops/JRPGShop/TraderListView.cs with following code:
    Code (CSharp):
    1. using UIWidgets;
    2. using System.Collections.Generic;
    3. using System;
    4.  
    5. namespace UIWidgetsSamples.Shops
    6. {
    7.     /// <summary>
    8.     /// TraderListView sort fields.
    9.     /// </summary>
    10.     public enum TraderListViewSortFields
    11.     {
    12.         /// <summary>
    13.         /// Item name.
    14.         /// </summary>
    15.         ItemName,
    16.  
    17.         /// <summary>
    18.         /// Item available.
    19.         /// </summary>
    20.         ItemAvailable,
    21.  
    22.         /// <summary>
    23.         /// Price.
    24.         /// </summary>
    25.         Price,
    26.  
    27.         /// <summary>
    28.         /// Count.
    29.         /// </summary>
    30.         Count,
    31.     }
    32.  
    33.     /// <summary>
    34.     /// Trader list view.
    35.     /// </summary>
    36.     public class TraderListView : ListViewCustom<TraderListViewComponent,JRPGOrderLine>
    37.     {
    38.         TraderListViewSortFields currentSortField = TraderListViewSortFields.ItemName;
    39.  
    40.         Dictionary<int,Comparison<JRPGOrderLine>> sortComparers;
    41.  
    42.         /// <summary>
    43.         /// Start this instance.
    44.         /// </summary>
    45.         public override void Start()
    46.         {
    47.             sortComparers = new Dictionary<int,Comparison<JRPGOrderLine>>(){
    48.                 {(int)TraderListViewSortFields.ItemName, ItemNameComparer},
    49.                 {(int)TraderListViewSortFields.ItemAvailable, ItemAvailableComparer},
    50.                 {(int)TraderListViewSortFields.Price, PriceComparer},
    51.                 {(int)TraderListViewSortFields.Count, CountComparer},
    52.             };
    53.  
    54.             Sort = false;
    55.  
    56.             base.Start();
    57.         }
    58.  
    59.         /// <summary>
    60.         /// Toggle sort.
    61.         /// </summary>
    62.         /// <param name="field">Sort field.</param>
    63.         public void ToggleSort(TraderListViewSortFields field)
    64.         {
    65.             if (field==currentSortField)
    66.             {
    67.                 DataSource.Reverse();
    68.             }
    69.             else if (sortComparers.ContainsKey((int)field))
    70.             {
    71.                 currentSortField = field;
    72.  
    73.                 DataSource.Sort(sortComparers[(int)field]);
    74.             }
    75.         }
    76.  
    77.         #region used in Button.OnClick()
    78.         /// <summary>
    79.         /// Sort by Item name.
    80.         /// </summary>
    81.         public void SortByItemName()
    82.         {
    83.             ToggleSort(TraderListViewSortFields.ItemName);
    84.         }
    85.  
    86.         /// <summary>
    87.         /// Sort by Item available.
    88.         /// </summary>
    89.         public void SortByItemAvailable()
    90.         {
    91.             ToggleSort(TraderListViewSortFields.ItemAvailable);
    92.         }
    93.  
    94.         /// <summary>
    95.         /// Sort by Price.
    96.         /// </summary>
    97.         public void SortByPrice()
    98.         {
    99.             ToggleSort(TraderListViewSortFields.Price);
    100.         }
    101.  
    102.         /// <summary>
    103.         /// Sort by Count.
    104.         /// </summary>
    105.         public void SortByCount()
    106.         {
    107.             ToggleSort(TraderListViewSortFields.Count);
    108.         }
    109.         #endregion
    110.  
    111.         #region Items comparers
    112.         /// <summary>
    113.         /// Item name comparer.
    114.         /// </summary>
    115.         /// <param name="x">First JRPGOrderLine.</param>
    116.         /// <param name="y">Second JRPGOrderLine.</param>
    117.         /// <returns>A 32-bit signed integer that indicates whether X precedes, follows, or appears in the same position in the sort order as the Y parameter.</returns>
    118.         static protected int ItemNameComparer(JRPGOrderLine x, JRPGOrderLine y)
    119.         {
    120.             return x.Item.Name.CompareTo(y.Item.Name);
    121.         }
    122.  
    123.         /// <summary>
    124.         /// Item available comparer.
    125.         /// </summary>
    126.         /// <param name="x">First JRPGOrderLine.</param>
    127.         /// <param name="y">Second JRPGOrderLine.</param>
    128.         /// <returns>A 32-bit signed integer that indicates whether X precedes, follows, or appears in the same position in the sort order as the Y parameter.</returns>
    129.         static protected int ItemAvailableComparer(JRPGOrderLine x, JRPGOrderLine y)
    130.         {
    131.             if (x.Item.Count==y.Item.Count)
    132.             {
    133.                 return 0;
    134.             }
    135.             if (x.Item.Count==-1)
    136.             {
    137.                 return 1;
    138.             }
    139.             if (y.Item.Count==-1)
    140.             {
    141.                 return -1;
    142.             }
    143.             return x.Item.Count.CompareTo(y.Item.Count);
    144.         }
    145.  
    146.         /// <summary>
    147.         /// Price comparer.
    148.         /// </summary>
    149.         /// <param name="x">First JRPGOrderLine.</param>
    150.         /// <param name="y">Second JRPGOrderLine.</param>
    151.         /// <returns>A 32-bit signed integer that indicates whether X precedes, follows, or appears in the same position in the sort order as the Y parameter.</returns>
    152.         static protected int PriceComparer(JRPGOrderLine x, JRPGOrderLine y)
    153.         {
    154.             return x.Price.CompareTo(y.Price);
    155.         }
    156.  
    157.         /// <summary>
    158.         /// Count comparer.
    159.         /// </summary>
    160.         /// <param name="x">First JRPGOrderLine.</param>
    161.         /// <param name="y">Second JRPGOrderLine.</param>
    162.         /// <returns>A 32-bit signed integer that indicates whether X precedes, follows, or appears in the same position in the sort order as the Y parameter.</returns>
    163.         static protected int CountComparer(JRPGOrderLine x, JRPGOrderLine y)
    164.         {
    165.             return x.Count.CompareTo(y.Count);
    166.         }
    167.         #endregion
    168.     }
    169. }
    And then add button component with onclick TraderListView.SortBy*() to header gameobjects like this:
     
    EmeralLotus likes this.
  28. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Amazing.... Thanks for the quick update and great example. Cheers.
     
  29. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    I must have missed something, because even after having used the standard Unity UI quite a bit, I cannot even use a simple button with this asset.

    My problem is that I cannot display the 'hovered' state of the 'ButtonBig' component.
    I presume it's because you haven't used an 'Image', but a 'RawImage' instead.

    What I did was to select 'Sprite Swap', and to fill the 'hovered', 'pressed' and 'disabled' states, as usual with Unity UI.
    Then I ran into a problem, because all my UI textures are in a texture configured as 'Sprite (2D and UI)' (as for any standard Unity UI component) and set as 'Multiple'.
    That way I can pack all the images in one texture.
    The problem is that it doesn't work with 'raw image'.

    In addition, there's a message in the button, indicating 'You must have a Image target in order to use a sprite swap transition.'.
    So, I think it's not possible with your widgets to use 'sprite swap' (I have the same problem with the tabs, and there are probably others like that), can you confirm it?



    Also, I've seen that you've let the 'Raycast target' for all components, even the 'Text' components.
    Is there a technical or feature reason to do all these casts?

    I usually remove all the unnecessary raycasts for performance reasons, because most of them are usually useless (especially the text ones).


    And to finish with, I've also seen that when the mouse is over one of your button, then the panel under is isn't hovered anymore.
    When a standard Unity UI button is hovered, then the panel it's on is also considered as being hovered.
    That means that it's possible with Unity UI to have a 'hover' or 'selected' state for a panel, while it may not be possible with some New UI Widgets.
    Did I missed something or is it confirmed?

    [edit] My bad for the mouse over thing, I just forgot to disable the navigation, it works well with New UI Widgets.
    Also, I've managed to make the tabs work with the 'Sprites swap', but not without replacing New UI Widgets buttons by the standard Unity UI ones.
    Is there an easier way to achieve that result?
     
    Last edited: Sep 1, 2017
  30. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    ButtonBig and ButtonSmall is just same Unity UI button with different image, they needed only if you want to make test ui scene in same style without mixing default Unity UI style with UI Widgets style.
    No one UI Widgets scripts require using ButtonBig and ButtonSmall.
    So you can use default Unity UI button.

    Regarding tabs - you can add Selectable component to use sprite swap or color tint.

    It's legacy reason, "Raycast target" added in Unity 5.2, UI Widgets works with Unity 4.6, 4.7, 5.0, 5.1 where it's not available.
    I never meet performance problems with "Raycast target". Is there any performance test about it?

    Please check if Selectable component used on both panels.
     
  31. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Can you explain more about this problem?

    Maybe replacing RawImage component with Image component and specifying it as Button.TargetGraphic will help, so you can use sprite swap.
     
  32. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Thanks for your reactivity.

    When I hover over a button tab, I'd like it to be in an hovered state, as standard buttons.


    For the panel itself, you're right, selectable is the way to go.
     
  33. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    For using Sprite Swap replace RawImage with Image component, and set it as Button.TargetGraphic.
     
  34. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    It works well, thanks.
    Out of curiosity, I only used image for UI components, what are the advantages of using RawImage?


    About the raycasting, I haven't profiled it yet, but raycasting is notorious to be slow, so it's best to avoid it when unnecessary.
    For example the border of the tab buttons, or all the texts.
    Also, in some cases disabling raycasting can provide or remove a feature.
    For example in a slider, if only the handle has raycasting, but not the background, then it is not possible to directly teleport the handle, you have to grab it and move it. Sometimes it's preferred, depending on the situation.


    For now I'm happy with New UI Widgets, it's close enough from the standard Unity UI and there are a lot of components.
    And your switch is way better than the one I did.
     
  35. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    I had some problem with Image and tried to solve it using RawImage, but I cannot remember what it was and was RawImage solve it or not.
     
  36. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    I also have a few things like that in my code.
    Finally, I've chosen to simply use the standard Unity buttons for the tabs, it seems to work well and it's more simple.


    I noticed that there are no scrollbar with buttons on both sides, it would very very handy for scrollviews, listviews, etc.
    Is it planned to add them?
     
  37. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    Added ScrollButtons component in 1.9.2b14
    You can check it in Miscellaneous tab in sample scene.
     
    Last edited: Sep 2, 2017
  38. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Great!
    For some unknown reasons I can't download it, but that's no problem, I'm in no hurry and I can wait.

    The important thing is that it will ultimately cover all my needs, and for now you're even exceeding them.
    Continue the good work!
     
  39. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    From what I understand of the templates (I'm using a DialogTemplate), it seems necessary to have the template in the scene.

    Is there a way to use 'Resources.Load()' in order to get the prefabed template, and then use it?
    What I'd like would be to avoid having to place the prefab in the scene, I need to be able to create components purely from script.
    I tried a few things, but so far I've been un-successful.
     
  40. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    It not necessary, only difference you need to specify canvas in dialog.Show() call, otherwise dialog gameobject will be root element and not visible because it not in canvas.

    You can specify prefab from assets (Project view), not from scene.
    Or you can load from Resources folder:
    Code (CSharp):
    1.             //path to prefab relative to Resources folder without extension
    2.             var dialog_go = Resources.Load<GameObject>("DialogTemplateSampleResources");
    3.             var dialog = dialog_go.GetComponent<Dialog>().Template();
    Sample code:
    Code (CSharp):
    1.  
    2.         public void ShowDialogSimple()
    3.         {
    4.             var canvas = Utilites.FindTopmostCanvas(transform).GetComponent<Canvas>();
    5.  
    6.             //var dialog = dialogSample.Template();//can be prefab from Project view
    7.             // or load from resources folder
    8.             var dialog_go = Resources.Load<GameObject>("DialogTemplateSampleResources");
    9.             var dialog = dialog_go.GetComponent<Dialog>().Template();
    10.  
    11.             dialog.Show(
    12.                 title: "Simple Dialog",
    13.                 message: "Simple dialog with only close button.",
    14.                 buttons: new DialogActions(){
    15.                     {"Close", Dialog.Close},
    16.                 },
    17.                 focusButton: "Close",
    18.                 canvas: canvas
    19.             );
    20.         }
    21.  
     
  41. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    Thanks!
    I feel so dumb about the Canvas thing... A mistake I will never make again.

    And it's good to know about the 'Utilites' thing, it will be handy.
    Thanks again for your fast and efficient answers.
     
  42. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Hi. I just bought the asset and so far it seems to be quite handy. I have a few questions already:

    - I do not see a sidebar component available (I mean the one that is in the demo listed as "sidebar"). Where can I find it?

    - Is there a support for themes/UI styles or are you planning to add one? I guess right now I just have to manually change all my GUI element look&feel by hand. It is a bit tedious and I dont like the default gold color at all =).

    - How do I make it so that only one item in treeview can be selected at once? I was thinking of hooking a function to OnSelect(Int 32, ListViewItem) and deselecting all items there and then selecting only the clicked one, but I dont know how to deselect the items (or if this is the proper way to do it)

    - When I hover over a TreeView, the background image changes. I think this has to do with the Mask script in the Viewport object. But how do I change the mask image? And how I disable the whole background image change on hover?
     
    Last edited: Sep 13, 2017
  43. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    It's literally component, so it's added with "Add component", not with context menu.


    I'll try to make tool for changing style.

    Disable "Multiple" checkbox in Inspector window.

    To deselect node you can use TreeView.Deselect(index) or TreeView.Deselect(node).
    TreeView.SelectedNodes and TreeView.SelectedIndices give you selected nodes or selected indices.

    This is done with Selectable component on TreeView gameobject.
    Remove it or change settings.
     
    Last edited: Sep 13, 2017
  44. jariwake

    jariwake

    Joined:
    Jun 2, 2017
    Posts:
    100
    Thank you for quick answers! It seems I missed a couple of quite obvious things (although I would rename "Multiple" to "Select multiple" or "Multiselect" or something more descriptive)
     
  45. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    I have seen that the 'Awake()' method calls the 'Start()' method in the ListView.
    Is there a technical reason?
    Because it effectively makes the 'Start()' method useless, as normally it is called after the 'Awake()' method (and not called when the component is disabled, while the 'Awake()' method is called even if the component is disabled).

    Also, the 'Start()' method is guaranteed to be called only once, but now it isn't anymore as it will be called twice if the component is enabled.

    I think it goes against Unity architecture.
    It forces us to protect the overrided 'Start()' methods against further calls and it also prevent us to do some initialization only when the component is disabled.


    The only workaround I have found is to skip the first call to the 'Start()' method in order to simulate the real behaviour of the 'Start()' method.
     
  46. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    It was - ListView worked incorrectly if you tried to use it before Start() was called, it's also fixed long ago, but I forgot to remove Start() call from Awake.
     
  47. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    OK, that explains a few things.
    Here is what you can do in order to provide standard MonoBehaviour behaviour for the 'Start()' method to the classes that inherit from yours:
    - Create a 'Init()' or 'Reinit()' method or whatever you want to call it, and put in it all the content of the 'Start()' method
    - Replace all calls to the 'Start()' method (not only coming from 'Awake()', but all the calls) to calls to the newly created 'Init()' method
    - Add a call to the 'Init()' method in all the 'Start()' methods you already have

    The idea is just to mirror your current 'Start()' methods with another one.
    That way, when we'll inherit from any of your component, our 'Start()' methods will behave exactly as they are supposed to according to Unity architecture.
    And it will have no impact on your own code as long as you use the same virtual/override than the 'Start()' methods with the newly created 'Init()' methods.
     
  48. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    It's already done, will be available with next beta 17.
     
  49. Gladyon

    Gladyon

    Joined:
    Sep 10, 2015
    Posts:
    389
    That's great, thanks.
     
  50. ilih

    ilih

    Joined:
    Aug 6, 2013
    Posts:
    1,408
    1.9.2 beta 17 available.