Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Favorites Tab[s] - your favorite assets and game objects

Discussion in 'Assets and Asset Store' started by Flipbookee, Sep 3, 2012.

  1. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    57
    FWIW, the project is fairly complicated, with dozens of add in packages e.g. Multiplayer, IAP, Addressables + CCD, Remote Config, Economy, and tons of asset store packages like Odin, etc. However, it all played along nicely until recently. Also can verify it still occurs with Unity 2022.3.8f1.
     
    Flipbookee likes this.
  2. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,749
    Some good news:

    Favorites Tabs
    version 1.3.1

    has just been released on the Asset Store
    There's an important fix in this version, the one for the bug that made stars change their color, so definitely, get this update.

    These are the changes:
    - Fixed color of stars changing by itself on reloading script assemblies - thanks @stylophone and @sampenguin
    - Fixed item drag starting too soon in a favorites tab when using a hi-res pointing device - thanks @ismail_koroglu

    Big thanks to everyone who helped me isolate and fix those bugs!

    Enjoy :cool:
     
  3. sampenguin

    sampenguin

    Joined:
    Feb 1, 2011
    Posts:
    57
    Can confirm 1.3.1 fixes my issue. Thanks for the quick turnaround!
     
    Flipbookee likes this.
  4. lgarczyn

    lgarczyn

    Joined:
    Nov 23, 2014
    Posts:
    41
    I've purchased the asset, and it's very good!

    But there is a tragic lack in shortcutable MenuItem

    First, shortcuts to select a specific item in the list view. I've done this through modifying the asset:

    in DoListView:
    Code (CSharp):
    1.  
    2. EditorGUIUtility.SetIconSize(new Vector2(16f, 16f));
    3. GUI.enabled = enable;
    4. GUIContent content = new (item.guiContent);
    5. content.text = $"{index}: {content.text}";
    6. labelStyle.Draw(rcItem, content, false, false, on, focused);
    7. GUI.enabled = wasEnabled;
    8.  
    in FavoritesTab:
    Code (CSharp):
    1.  
    2.  
    3. const string WindowPath = "Tools/Favorites Tab";
    4. // Shortcuts
    5. const string ShortcutPath = WindowPath + " Shortcuts/";
    6. const string ShortcutItemPath = ShortcutPath + "/Open Favorite ";
    7.  
    8. static void OpenItem(int i)
    9. {
    10.   GetWindow<FavoritesTab>().SelectItem(i);
    11. }
    12. static bool ValidateOpenItem(int i)
    13. {
    14.   return i >= 0 && (GetWindow<FavoritesTab>()?.listViewItems?.Length ?? 0) > i;
    15. }
    16.  
    17. [MenuItem(ShortcutItemPath + "0", false, 10)]
    18. static void OpenItem0() => OpenItem(0);
    19. [MenuItem(ShortcutItemPath + "1", false, 10)]
    20. static void OpenItem1() => OpenItem(1);
    21. [MenuItem(ShortcutItemPath + "2", false, 10)]
    22. static void OpenItem2() => OpenItem(2);
    23. [MenuItem(ShortcutItemPath + "3", false, 10)]
    24. static void OpenItem3() => OpenItem(3);
    25. [MenuItem(ShortcutItemPath + "4", false, 10)]
    26. static void OpenItem4() => OpenItem(4);
    27. [MenuItem(ShortcutItemPath + "5", false, 10)]
    28. static void OpenItem5() => OpenItem(5);
    29. [MenuItem(ShortcutItemPath + "6", false, 10)]
    30. static void OpenItem6() => OpenItem(6);
    31. [MenuItem(ShortcutItemPath + "7", false, 10)]
    32. static void OpenItem7() => OpenItem(7);
    33. [MenuItem(ShortcutItemPath + "8", false, 10)]
    34. static void OpenItem8() => OpenItem(8);
    35. [MenuItem(ShortcutItemPath + "9", false, 10)]
    36. static void OpenItem9() => OpenItem(9);
    37.  
    38. [MenuItem(ShortcutItemPath + "0", true, 10)]
    39. static bool ValidateOpenItem0() => ValidateOpenItem(0);
    40. [MenuItem(ShortcutItemPath + "1", true, 10)]
    41. static bool ValidateOpenItem1() => ValidateOpenItem(1);
    42. [MenuItem(ShortcutItemPath + "2", true, 10)]
    43. static bool ValidateOpenItem2() => ValidateOpenItem(2);
    44. [MenuItem(ShortcutItemPath + "3", true, 10)]
    45. static bool ValidateOpenItem3() => ValidateOpenItem(3);
    46. [MenuItem(ShortcutItemPath + "4", true, 10)]
    47. static bool ValidateOpenItem4() => ValidateOpenItem(4);
    48. [MenuItem(ShortcutItemPath + "5", true, 10)]
    49. static bool ValidateOpenItem5() => ValidateOpenItem(5);
    50. [MenuItem(ShortcutItemPath + "6", true, 10)]
    51. static bool ValidateOpenItem6() => ValidateOpenItem(6);
    52. [MenuItem(ShortcutItemPath + "7", true, 10)]
    53. static bool ValidateOpenItem7() => ValidateOpenItem(7);
    54. [MenuItem(ShortcutItemPath + "8", true, 10)]
    55. static bool ValidateOpenItem8() => ValidateOpenItem(8);
    56. [MenuItem(ShortcutItemPath + "9", true, 10)]
    57. static bool ValidateOpenItem9() => ValidateOpenItem(9);
    58.  
    59.  
    Second, a shortcut to add the selection as a favorite, or remove it. Again, not easy to add

    in FavoritesList
    Code (CSharp):
    1.  
    2.  
    3. public void Toggle(UnityEngine.Object target)
    4. {
    5.   if (AssetDatabase.Contains(target))
    6.   {
    7.    if (AssetDatabase.TryGetGUIDAndLocalFileIdentifier(target, out string guid, out long _))
    8.    {
    9.     ToggleAsset(guid);
    10.    }
    11.   }
    12.   else
    13.    ToggleGameObject(target.GetInstanceID());
    14. }
    15.  
    16. public int Contains(UnityEngine.Object target)
    17. {
    18.   if (!AssetDatabase.Contains(target)) return Contains(target.GetInstanceID());
    19.  
    20.   return AssetDatabase.TryGetGUIDAndLocalFileIdentifier(target, out string guid, out long _) ? Contains(guid) : -1;
    21. }
    22.  
    23. public void Add(UnityEngine.Object target)
    24. {
    25.   if (Contains(target) == -1)
    26.    Toggle(target);
    27. }
    28.  
    29. public void Remove(UnityEngine.Object target)
    30. {
    31.   if (Contains(target) > -1)
    32.    Toggle(target);
    33. }
    34.  
    in FavoritesTab
    Code (CSharp):
    1.  
    2.  
    3. [MenuItem(ShortcutPath + "Save Current Selection", true, 11)]
    4. static bool ValidateSaveCurrentSelection()
    5. {
    6. return Selection.objects.Length > 0 && favorites.isLoaded;
    7. }
    8.  
    9. [MenuItem(ShortcutPath + "Save Current Selection", false, 11)]
    10. static void SaveCurrentSelection()
    11. {
    12. if (Selection.objects.Length > 5 &&
    13.      EditorUtility.DisplayDialog("Warning",
    14.       $"Adding {Selection.objects.Length} items to favorites, confirm?",
    15.       "Proceed") == false) return;
    16. foreach (UnityEngine.Object item in Selection.objects) favorites.Add(item);
    17. RefreshAllTabs();
    18. }
    19.  
    20. [MenuItem(ShortcutPath + "Remove Current Selection", true, 11)]
    21. static bool ValidateRemoveCurrentSelection()
    22. {
    23. return Selection.objects.Length > 0 && favorites.isLoaded;
    24. }
    25.  
    26. [MenuItem(ShortcutPath + "Remove Current Selection", false, 11)]
    27. static void RemoveCurrentSelection()
    28. {
    29. foreach (UnityEngine.Object item in Selection.objects) favorites.Remove(item);
    30.   RefreshAllTabs();
    31. }
    32.  
    Adding descending sort order is simple, but hard to paste here, since the modifications required are all over.

    It's a bit disappointing that this asset, though working absolutely fine and clearly a work of love, doesn't really have any attempt at modularity. It's hard to do anything without diving deep in the code, which is less than perfectly commented.
     
    Last edited: Oct 20, 2023
    Flipbookee and Lars-Steenhoff like this.
  5. Flipbookee

    Flipbookee

    Joined:
    Jun 2, 2012
    Posts:
    2,749
    @lgarczyn, WOW, I'm impressed. Thanks for all these additions! :cool:

    A new version should be available soon, right after I finish and release the work I'm doing on Script Inspector 3 (hopefully this weekend). I'll try to include your improvements in it.

    By the way, Script Inspector 3 is on sale right now, but you deserve a free copy for this, so message me if you're interested :rolleyes:
     
    Lars-Steenhoff likes this.