Esempio n. 1
0
        internal static List <string> GetPathsWithExtensions(string[] extensions, string[] exceptions = null)
        {
            exceptions = (exceptions ?? new string[0]);
            DirectoryInfo          directoryInfo     = new DirectoryInfo(ValidatorData.SCAN_PATH);
            HashSet <string>       allowedExtensions = new HashSet <string>(extensions, System.StringComparer.OrdinalIgnoreCase);
            IEnumerable <FileInfo> source            = from f in directoryInfo.GetFiles("*", SearchOption.AllDirectories)
                                                       where allowedExtensions.Contains(f.Extension)
                                                       select f;
            IEnumerable <string> source2 = from f in source
                                           select ValidatorData.ToProjectRelativePath(f.FullName) into p
                                               where exceptions.All((string e) => !Path.GetDirectoryName(p).Contains(e))
                                           select p;

            return(source2.ToList <string>());
        }
Esempio n. 2
0
        internal static List <string> GetPathsWithExtensions(string[] extensions, string[] exceptions = null)
        {
            string[] strArrays = exceptions;
            strArrays = strArrays ?? new string[0];
            DirectoryInfo          directoryInfo = new DirectoryInfo(ValidatorData.SCAN_PATH);
            HashSet <string>       strs          = new HashSet <string>(extensions, StringComparer.OrdinalIgnoreCase);
            IEnumerable <FileInfo> files         =
                from f in directoryInfo.GetFiles("*", SearchOption.AllDirectories)
                where strs.Contains(f.Extension)
                select f;
            IEnumerable <string> projectRelativePath =
                from f in files
                select ValidatorData.ToProjectRelativePath(f.FullName) into p
                    where strArrays.All <string>((string e) => !Path.GetDirectoryName(p).Contains(e))
                select p;

            return(projectRelativePath.ToList <string>());
        }
Esempio n. 3
0
        public void OnGUI()
        {
            Checklist checkList = Checklist.GetCheckList();

            GUILayout.Space(10f);
            EditorGUILayout.LabelField("Package Validator", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.Space(2f);
            GUIStyle gUIStyle = new GUIStyle(EditorStyles.label)
            {
                wordWrap = true
            };

            EditorGUILayout.LabelField("Scan your package to check that it does not have common package submission mistakes. Passing this scan does not guarantee that your package will get accepted as the final decision is made by the Unity Asset Store team.\n\nYou can upload your package even if it does not pass some of the criteria as it depends on the type of assets that you upload. For more information, view the messages next to the criteria in the checklist or contact our support team.", gUIStyle, new GUILayoutOption[0]);
            GUILayout.Space(10f);
            EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
            this.PackagePath = EditorGUILayout.TextField("Package path:", this.PackagePath, new GUILayoutOption[0]);
            GUI.SetNextControlName("Set Path");
            if (GUILayout.Button("Set Path", new GUILayoutOption[] { GUILayout.ExpandWidth(false) }))
            {
                string str = EditorUtility.OpenFolderPanel("Select Package Folder", string.Empty, string.Empty);
                if (!string.IsNullOrEmpty(str))
                {
                    string projectRelativePath = ValidatorData.ToProjectRelativePath(str);
                    if (this.IsValidPath(projectRelativePath))
                    {
                        this.PackagePath = projectRelativePath;
                        GUI.FocusControl("Set Path");
                    }
                }
            }
            if (!string.IsNullOrEmpty(this.PackagePath))
            {
                ValidatorData.SetScanPath(this.PackagePath);
            }
            GUILayout.Space(15f);
            if (GUILayout.Button("Scan", new GUILayoutOption[] { GUILayout.Width(100f) }) && this.IsValidPath(this.PackagePath))
            {
                this.showChecklist = true;
                checkList.Scan();
                this.showErrorItems   = true;
                this.showWarningItems = true;
                this.showPassItems    = false;
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField(string.Empty, GUI.skin.horizontalSlider, new GUILayoutOption[0]);
            GUIStyle gUIStyle1 = new GUIStyle(EditorStyles.boldLabel)
            {
                alignment = TextAnchor.MiddleCenter
            };

            if (!this.showChecklist)
            {
                GUILayout.Label("Scan the selected Package path to receive validation feedback.", gUIStyle1, new GUILayoutOption[0]);
            }
            else
            {
                GUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
                EditorGUILayout.LabelField("Checklist", EditorStyles.boldLabel, new GUILayoutOption[] { GUILayout.MaxWidth(75f) });
                GUILayout.FlexibleSpace();
                this.showPassItems    = GUILayout.Toggle(this.showPassItems, new GUIContent(this.checkIcon, "Passed"), EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(30f) });
                this.showWarningItems = GUILayout.Toggle(this.showWarningItems, new GUIContent(this.warningIcon, "Warnings"), EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(30f) });
                this.showErrorItems   = GUILayout.Toggle(this.showErrorItems, new GUIContent(this.errorIcon, "Errors"), EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(30f) });
                EditorGUILayout.EndHorizontal();
                this.scrollPos = EditorGUILayout.BeginScrollView(this.scrollPos, new GUILayoutOption[0]);
                GUILayout.Space(6f);
                GUIStyle gUIStyle2 = new GUIStyle(EditorStyles.foldout)
                {
                    fontStyle = FontStyle.Bold
                };
                IEnumerable <ChecklistItem> checks =
                    from c in checkList.Checks
                    where c.Status == CheckStatus.Error & !c.Failed
                    select c;
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                this.showErrorItems = EditorGUILayout.Foldout(this.showErrorItems, string.Concat("     Errors (", checks.Count <ChecklistItem>(), ")"), gUIStyle2);
                this.DrawEntryIcon(this.errorIcon, 16);
                GUILayout.EndHorizontal();
                GUILayout.Space(6f);
                if (this.showErrorItems)
                {
                    IEnumerator <ChecklistItem> enumerator = checks.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            this.ChecklistItemGUI(enumerator.Current);
                            GUILayout.Space(6f);
                        }
                    }
                    finally
                    {
                        if (enumerator == null)
                        {
                        }
                        enumerator.Dispose();
                    }
                }
                checks =
                    from c in checkList.Checks
                    where (c.Status == CheckStatus.Warning ? true : c.Failed)
                    orderby c.Failed
                    select c;
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                this.showWarningItems = EditorGUILayout.Foldout(this.showWarningItems, string.Concat("     Warnings (", checks.Count <ChecklistItem>(), ")"), gUIStyle2);
                this.DrawEntryIcon(this.warningIcon, 16);
                GUILayout.EndHorizontal();
                GUILayout.Space(6f);
                if (this.showWarningItems)
                {
                    IEnumerator <ChecklistItem> enumerator1 = checks.GetEnumerator();
                    try
                    {
                        while (enumerator1.MoveNext())
                        {
                            this.ChecklistItemGUI(enumerator1.Current);
                            GUILayout.Space(6f);
                        }
                    }
                    finally
                    {
                        if (enumerator1 == null)
                        {
                        }
                        enumerator1.Dispose();
                    }
                }
                checks =
                    from c in checkList.Checks
                    where c.Status == CheckStatus.Pass & !c.Failed
                    select c;
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                this.showPassItems = EditorGUILayout.Foldout(this.showPassItems, string.Concat("     Passed (", checks.Count <ChecklistItem>(), ")"), gUIStyle2);
                this.DrawEntryIcon(this.checkIcon, 16);
                GUILayout.EndHorizontal();
                GUILayout.Space(6f);
                if (this.showPassItems)
                {
                    IEnumerator <ChecklistItem> enumerator2 = checks.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            this.ChecklistItemGUI(enumerator2.Current);
                            GUILayout.Space(6f);
                        }
                    }
                    finally
                    {
                        if (enumerator2 == null)
                        {
                        }
                        enumerator2.Dispose();
                    }
                }
                EditorGUILayout.EndScrollView();
            }
        }