예제 #1
0
 internal static Checklist GetCheckList()
 {
     Checklist._checklist = ValidatorData.LoadAssetAtPath <Checklist>(ValidatorData.MANAGER_PATH);
     if (Checklist._checklist == null)
     {
         Checklist.CreateChecklist();
     }
     return(Checklist._checklist);
 }
예제 #2
0
 private static void CreateChecklist()
 {
     Checklist._checklist = ScriptableObject.CreateInstance <Checklist>();
     AssetDatabase.CreateAsset(Checklist._checklist, ValidatorData.MANAGER_PATH);
     foreach (ValidatorData.CheckItemData itemDatum in ValidatorData.ItemData)
     {
         Checklist._checklist.AddCheck(itemDatum);
     }
     EditorUtility.SetDirty(Checklist._checklist);
     AssetDatabase.ImportAsset(ValidatorData.MANAGER_PATH);
     AssetDatabase.SaveAssets();
 }
예제 #3
0
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            Checklist checklist = ValidatorData.LoadAssetAtPath <Checklist>(ValidatorData.MANAGER_PATH);

            if (checklist == null)
            {
                return;
            }
            foreach (ChecklistItem checklistItem in checklist.Checks)
            {
                checklistItem.CheckAssetsForDeletion(deletedAssets);
                checklistItem.CheckAssetsForMove(movedFromAssetPaths, movedAssets);
            }
        }
예제 #4
0
        public void Scan()
        {
            foreach (ChecklistItem check in this.Checks)
            {
                check.Clear();
            }
            List <Scanner> scanners = new List <Scanner>()
            {
                new ExtensionScanner(Checklist.GetCheck(CheckType.Demo), ValidatorData.DEMO_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Jpg), ValidatorData.JPG_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Prepackage), ValidatorData.PACKAGE_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Documentation), ValidatorData.DOC_EXTENSIONS, ValidatorData.EXCLUDED_DIRECTORIES),
                new ExtensionScanner(Checklist.GetCheck(CheckType.JavaScript), ValidatorData.JS_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Mp3), ValidatorData.MP3_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Video), ValidatorData.VIDEO_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Executable), ValidatorData.EXECUTABLE_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.SpeedTree), ValidatorData.SPEEDTREE_EXTENSIONS, null),
                new PrefabScanner(Checklist.GetCheck(CheckType.PrefabCollider), Checklist.GetCheck(CheckType.PrefabTransform), Checklist.GetCheck(CheckType.PrefabEmpty), Checklist.GetCheck(CheckType.LODs)),
                new StandardAssetScanner(Checklist.GetCheck(CheckType.StandardAssets)),
                new ReferenceScanner(Checklist.GetCheck(CheckType.MissingReference)),
                new ModelScanner(Checklist.GetCheck(CheckType.ModelPrefabs), Checklist.GetCheck(CheckType.Mixamo), Checklist.GetCheck(CheckType.Animation), Checklist.GetCheck(CheckType.Orientation)),
                new TextureScanner(Checklist.GetCheck(CheckType.Texture))
            };

            foreach (Scanner scanner in scanners)
            {
                try
                {
                    scanner.Scan();
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    Debug.LogError(string.Concat("Validator check failed with ", scanner.GetType().ToString(), "\n\n", exception.ToString()));
                    ChecklistItem[] getChecklistItems = scanner.GetChecklistItems;
                    for (int i = 0; i < (int)getChecklistItems.Length; i++)
                    {
                        getChecklistItems[i].Failed = true;
                    }
                }
            }
            foreach (ChecklistItem checklistItem in this.Checks)
            {
                checklistItem.UpdateState();
            }
        }
예제 #5
0
        public void Scan()
        {
            foreach (ChecklistItem checklistItem in this.Checks)
            {
                checklistItem.Clear();
            }
            List <Scanner> list = new List <Scanner>
            {
                new ExtensionScanner(Checklist.GetCheck(CheckType.Demo), ValidatorData.DEMO_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Jpg), ValidatorData.JPG_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Prepackage), ValidatorData.PACKAGE_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Documentation), ValidatorData.DOC_EXTENSIONS, ValidatorData.EXCLUDED_DIRECTORIES),
                new ExtensionScanner(Checklist.GetCheck(CheckType.JavaScript), ValidatorData.JS_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Mp3), ValidatorData.MP3_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Video), ValidatorData.VIDEO_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.Executable), ValidatorData.EXECUTABLE_EXTENSIONS, null),
                new ExtensionScanner(Checklist.GetCheck(CheckType.SpeedTree), ValidatorData.SPEEDTREE_EXTENSIONS, null),
                new PrefabScanner(Checklist.GetCheck(CheckType.PrefabCollider), Checklist.GetCheck(CheckType.PrefabTransform), Checklist.GetCheck(CheckType.PrefabEmpty), Checklist.GetCheck(CheckType.LODs)),
                new ReferenceScanner(Checklist.GetCheck(CheckType.MissingReference)),
                new ModelScanner(Checklist.GetCheck(CheckType.ModelPrefabs), Checklist.GetCheck(CheckType.Mixamo), Checklist.GetCheck(CheckType.Animation), Checklist.GetCheck(CheckType.Orientation)),
                new TextureScanner(Checklist.GetCheck(CheckType.Texture))
            };

            foreach (Scanner scanner in list)
            {
                try
                {
                    scanner.Scan();
                }
                catch (System.Exception ex)
                {
                    Debug.LogError("Validator check failed with " + scanner.GetType().ToString() + "\n\n" + ex.ToString());
                    foreach (ChecklistItem checklistItem2 in scanner.GetChecklistItems)
                    {
                        checklistItem2.Failed = true;
                    }
                }
            }
            foreach (ChecklistItem checklistItem3 in this.Checks)
            {
                checklistItem3.UpdateState();
            }
        }
예제 #6
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();
            }
        }