Addressables checkbox in inspector is not showing its true value

Hi

I have a small quality of life feature request. I would like that the addressable checkbox in the inspector to show if an item is addressable or not. Currently it only displays if it is addressable if the item itself is, but not if a parent folder is.
The asset itself:
6775895--783620--upload_2021-1-28_17-19-43.png
The parent folder:
6775895--783626--upload_2021-1-28_17-20-3.png

This makes it harder to know what items are actually addressables and which arent. (I just had a new guy on the team not understand why things worked because the assets didnt appear to be addressables).

I propose that the addressables checbox is greyed out (and showing its path) if it is addressabled (is that a word) through its parent folder.

1 Like

Agreed. However it should also indicate whether it’s the asset or the folder that is marked.

Also a huge quality of life would be if the assets/folders in Project window were somehow visually distinguished from others. I find myself clicking on each asset to check if they are marked way too often. Perhaps a small dot next to a name, or just a font change … italics or underline?

There are so many much needed and easy-to-identify QoL improvements. It feels as if the dev team is not using their own tool in any production environment. Addressables is a great concept and I wish nothing more than the devs taking a step back from the advanced features and polish the experience of the basics. Currently it’s very confusing, unintuitive and hard to navigate.

1 Like

It would have to be disabled too, as we currently have no control over the naming of assets addressed by folder (which I have no issue with).

6780005--784652--upload_2021-1-29_17-59-10.png

This is how I solved it for now. the A means its addressable

using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.AddressableAssets;
using UnityEditor.AddressableAssets.Settings;
using UnityEngine;
using Object = UnityEngine.Object;

public static class ProjectWindowOverride
{
    private static HashSet<string> paths;
    private static GUIStyle lineStyle;
    [InitializeOnLoadMethod]
    private static void Init()
    {
        EditorApplication.projectWindowItemOnGUI += OnHierarchyItemOnGUI;
    }

    private static void OnHierarchyItemOnGUI(string guid, Rect rect)
    {
        if (Application.isPlaying || Event.current.type != EventType.Repaint || !IsMainListAsset(rect))
        {
            return;
        }
        string assetPath = AssetDatabase.GUIDToAssetPath(guid);
        if (AssetDatabase.IsValidFolder(assetPath))
        {
            return;
        }
        var asset = AssetDatabase.LoadAssetAtPath<Object>(assetPath);
        if (asset == null)
        {
            // this entry could be Favourites or Packages. Ignore it.
            return;
        }

        if (lineStyle == null)
        {
            lineStyle = (GUIStyle) "TV Line";
        }
       
        var textDimensions = lineStyle.CalcSize(new GUIContent(asset.name));
        const float kIndentWidth = 14f;
        const float kIconWidth = 16f;
        const float kSpaceBetweenIconAndText = 2f;
        const float indent = kIndentWidth + kIconWidth + kSpaceBetweenIconAndText;
       
        if (DrawSizeLabel(rect, indent, textDimensions, assetPath)) return;

        DrawAddressableA(rect, indent, textDimensions, assetPath);
    }

    private static bool DrawSizeLabel(Rect rect, float indent, Vector2 textDimensions, string assetPath)
    {
        float leftOverWidth = rect.width - (indent + textDimensions.x + 60);
        if (leftOverWidth <= 0)
        {
            //Dont draw if theres no room
            return true;
        }

        var sizeLabel = new Rect(rect);
        sizeLabel.x += rect.width - 60;
        sizeLabel.width = 60;
        GUI.Label(sizeLabel, GetFormattedFileSize(assetPath));
        return false;
    }

    private static bool DrawAddressableA(Rect rect, float indent, Vector2 textDimensions, string assetPath)
    {
        float leftOverWidth = rect.width - (indent + textDimensions.x + 100);
        if (leftOverWidth <= 0)
        {
            //Dont draw if theres no room
            return true;
        }

        if (paths == null)
        {
            ExtractAddressablePaths(AddressableAssetSettingsDefaultObject.Settings, out paths);
        }


        if (paths != null && paths.Contains(assetPath))
        {
            var addressableLabel = new Rect(rect);
            addressableLabel.x += rect.width - 100;
            addressableLabel.width = 12;
            GUI.Label(addressableLabel, "A");
        }

        return false;
    }

    static void ExtractAddressablePaths(AddressableAssetSettings settings, out HashSet<string> paths)
    {
        paths = new HashSet<string>();
        foreach (AddressableAssetGroup group in settings.groups)
        {
            if (group == null)
                continue;
            foreach (AddressableAssetEntry entry in group.entries)
            {
                string convertedPath = entry.AssetPath;
                if (AssetDatabase.IsValidFolder(convertedPath))
                {
                    ExtractPathsFromFolder(convertedPath, paths);
                }
                else
                {
                    paths.Add(convertedPath);
                }
            }
        }
    }

    private static void ExtractPathsFromFolder(string path, HashSet<string> hashSet)
    {
        foreach (string filename in Directory.EnumerateFileSystemEntries(path, "*.*", SearchOption.AllDirectories))
        {
            string convertedPath = filename.Replace('\\', '/');
            hashSet.Add(convertedPath);
        }
    }

    public static string GetFormattedFileSize(string assetPath)
    {
        return EditorUtility.FormatBytes(GetFileSize(assetPath));
    }

    private static long GetFileSize(string assetPath)
    {
        string fullAssetPath = string.Concat(Application.dataPath.Substring(0, Application.dataPath.Length - 7), "/", assetPath);
        long size = new FileInfo(fullAssetPath).Length;
        return size;
    }

    private static bool IsMainListAsset(Rect rect)
    {
        // Don't draw details if project view shows large preview icons:
        if (rect.height > 20)
        {
            return false;
        }
        // Don't draw details if this asset is a sub asset:
        if (rect.x > 16)
        {
            return false;
        }
        return true;
    }
}
1 Like

I’ll pass this request to the team on your behalf!

1 Like

Wanted to pass a long that the team love the idea, and are going to look into it!

1 Like