Example #1
0
        public static bool IsFileIgrnoredBySettings(string path)
        {
            if (IgnoreTypes.Check(path, out _))
            {
                return(true);
            }
            if (IgnoredNonAssets(path))
            {
                return(true);
            }
            if (IgnoredPaths(path, out _))
            {
                return(true);
            }

            return(false);
        }
        static bool TryGetHelpInfo(SearchArg arg, out string msg, out MessageType msgType)
        {
            msgType = MessageType.Info;
            if (arg == null)
            {
                msg = default;
                return(false);
            }

            var path = arg.FilePath;

            if (string.IsNullOrEmpty(path))
            {
                msg = default;
                return(false);
            }

            if (SearchUtils.IgnoredPaths(path, out var subPath))
            {
                msg = $"Paths containing '{subPath}' are ignored. You could add or remove it in Settings tab";
                return(true);
            }

            if (SearchUtils.IgnoredNonAssets(path) && !path.Eq("Assets"))
            {
                msg = $"Asset is outside of Assets folder";
                return(true);
            }

            if (IgnoreTypes.Check(path, out var type))
            {
                if (AssetDatabase.IsValidFolder(path))
                {
                    var scenes = arg.UnusedScenesFiltered?.Count;
                    var files  = arg.UnusedAssetsFiltered?.Count;
                    if (scenes == 0 && files == 0)
                    {
                        msg = default;
                        return(false);
                    }

                    var b = new StringBuilder();
                    b.Append("This directory contains: ");
                    var any = false;

                    if (files > 0)
                    {
                        any = true;

                        b.Append($"unused files ({files})");
                    }

                    if (scenes > 0)
                    {
                        if (any)
                        {
                            b.Append(", ");
                        }
                        b.Append($"unused scenes ({scenes})");
                    }

                    b.Append(
                        ".\nYou could delete them pressing corresponding button to the right.\nIf you don't want it to be inspected, please add it to Ignore list in the Settings tab");
                    msg = b.ToString();
                    return(true);
                }

                msg = $"Assets of type '{type.Name}' are ignored. Please contact support if you need to change it";
                return(true);
            }

            // if (Filters.ScenePaths.GetEntitiesCount() == 0 && Filters.FileResultRows.GetEntitiesCount() == 0) {
            if (SearchUtils.IsUnused(path))
            {
                type = AssetDatabase.GetMainAssetTypeAtPath(path);
                var name = type.IsAssignableFromInverse(typeof(SceneAsset)) ? "scene" : "file";
                msg =
                    $"This {name} has no explicit serialized usages and potentially could be removed. If you don't want it to be inspected, please add the containing folder to ignore list";
                return(true);
            }

            msgType = default;
            msg     = default;
            return(false);
        }