public override void Scan()
 {
     foreach (string pathsWithExtension in ValidatorData.GetPathsWithExtensions(ValidatorData.PREFAB_EXTENSIONS, null))
     {
         GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(pathsWithExtension);
         if (gameObject == null)
         {
             this.emptyCheck.AddPath(pathsWithExtension);
         }
         else
         {
             if (PrefabScanner.NeedsCollider(gameObject))
             {
                 this.colliderCheck.AddPath(pathsWithExtension);
             }
             if (PrefabScanner.NeedsTransformReset(gameObject))
             {
                 this.transformCheck.AddPath(pathsWithExtension);
             }
             if (PrefabScanner.IsPrefabEmpty(gameObject))
             {
                 this.emptyCheck.AddPath(pathsWithExtension);
             }
             if (PrefabScanner.HasIncorrectLODs(gameObject))
             {
                 this.lodsCheck.AddPath(pathsWithExtension);
             }
         }
     }
 }
        public override void Scan()
        {
            IEnumerable <string> allAssetPaths =
                from p in AssetDatabase.GetAllAssetPaths()
                where ValidatorData.PathInAssetDir(p)
                select p;
            IEnumerator <string> enumerator = allAssetPaths.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    string     current    = enumerator.Current;
                    GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(current);
                    if (!(gameObject != null) || !ReferenceScanner.IsMissingReference(gameObject))
                    {
                        continue;
                    }
                    this.checklistItem.AddPath(current);
                }
            }
            finally
            {
                if (enumerator == null)
                {
                }
                enumerator.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void ScanForAnimations()
        {
Label0:
            foreach (string pathsWithExtension in ValidatorData.GetPathsWithExtensions(ValidatorData.MODEL_EXTENSIONS, null))
            {
                List <ModelImporterClipAnimation> modelImporterClipAnimations = new List <ModelImporterClipAnimation>();
                ModelImporter atPath = (ModelImporter)AssetImporter.GetAtPath(pathsWithExtension);
                modelImporterClipAnimations.AddRange(atPath.clipAnimations);
                modelImporterClipAnimations.AddRange(atPath.defaultClipAnimations);
                HashSet <string> strs = new HashSet <string>();
                int num = 0;
                while (num < modelImporterClipAnimations.Count)
                {
                    if (strs.Add(modelImporterClipAnimations[num].name))
                    {
                        num++;
                    }
                    else
                    {
                        this.animationCheck.AddPath(pathsWithExtension);
                        goto Label0;
                    }
                }
            }
        }
 private static bool NeedsTransformReset(GameObject go)
 {
     if (!ValidatorData.GetMeshes(go).Any <Mesh>())
     {
         return(false);
     }
     return(!go.transform.localToWorldMatrix.isIdentity);
 }
 private static bool NeedsCollider(GameObject go)
 {
     if (!ValidatorData.GetMeshes(go).Any <Mesh>())
     {
         return(false);
     }
     return(!go.GetComponentsInChildren <Collider>(true).Any <Collider>());
 }
Ejemplo n.º 6
0
        public override void Scan()
        {
            List <string> pathsWithExtensions = ValidatorData.GetPathsWithExtensions(this.extensions, this.exclusions);

            if (pathsWithExtensions.Any <string>())
            {
                this.checklistItem.AddPaths(pathsWithExtensions);
            }
        }
Ejemplo n.º 7
0
 internal static Checklist GetCheckList()
 {
     Checklist._checklist = ValidatorData.LoadAssetAtPath <Checklist>(ValidatorData.MANAGER_PATH);
     if (Checklist._checklist == null)
     {
         Checklist.CreateChecklist();
     }
     return(Checklist._checklist);
 }
Ejemplo n.º 8
0
 private void ScanForMixamo()
 {
     foreach (string pathsWithExtension in ValidatorData.GetPathsWithExtensions(new string[] { ".fbx" }, null))
     {
         if (!ValidatorUtils.IsMixamoFbx(pathsWithExtension))
         {
             continue;
         }
         this.mixamoCheck.AddPath(pathsWithExtension);
     }
 }
Ejemplo n.º 9
0
        private static bool NeedsCollider(GameObject go)
        {
            List <Mesh> meshes = ValidatorData.GetMeshes(go);

            if (!meshes.Any <Mesh>())
            {
                return(false);
            }
            Collider[] componentsInChildren = go.GetComponentsInChildren <Collider>(true);
            return(!componentsInChildren.Any <Collider>());
        }
Ejemplo n.º 10
0
 private static bool IsUpright(GameObject model)
 {
     Transform[] componentsInChildren = model.GetComponentsInChildren <Transform>(true);
     foreach (Transform transform in componentsInChildren)
     {
         if (transform.localRotation != Quaternion.identity && ValidatorData.GetMesh(transform))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 11
0
 private void ScanForOrientations()
 {
     foreach (string modelPath in ValidatorData.GetModelPaths())
     {
         GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(modelPath);
         if (ModelScanner.IsUpright(gameObject))
         {
             continue;
         }
         this.orientationCheck.AddPath(AssetDatabase.GetAssetPath(gameObject));
     }
 }
Ejemplo n.º 12
0
 private static bool IsUpright(GameObject model)
 {
     Transform[] componentsInChildren = model.GetComponentsInChildren <Transform>(true);
     for (int i = 0; i < (int)componentsInChildren.Length; i++)
     {
         Transform transforms = componentsInChildren[i];
         if (transforms.localRotation != Quaternion.identity && ValidatorData.GetMesh(transforms))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 13
0
        private void ScanForOrientations()
        {
            List <string> modelPaths = ValidatorData.GetModelPaths();

            foreach (string path in modelPaths)
            {
                GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(path);
                if (!ModelScanner.IsUpright(gameObject))
                {
                    this.orientationCheck.AddPath(AssetDatabase.GetAssetPath(gameObject));
                }
            }
        }
Ejemplo n.º 14
0
        public static List <Mesh> GetMeshes(GameObject go)
        {
            List <Mesh> list = new List <Mesh>();

            MeshFilter[]          componentsInChildren  = go.GetComponentsInChildren <MeshFilter>(true);
            SkinnedMeshRenderer[] componentsInChildren2 = go.GetComponentsInChildren <SkinnedMeshRenderer>(true);
            list.AddRange(from m in componentsInChildren
                          select m.sharedMesh);
            list.AddRange(from m in componentsInChildren2
                          select m.sharedMesh);
            return((from m in list
                    where ValidatorData.PathInAssetDir(AssetDatabase.GetAssetPath(m))
                    select m).ToList <Mesh>());
        }
Ejemplo n.º 15
0
 public override void Scan()
 {
     foreach (string pathsWithExtension in ValidatorData.GetPathsWithExtensions(ValidatorData.TEXTURE_EXTENSIONS, null))
     {
         Texture2D texture2D = new Texture2D(1, 1);
         texture2D.LoadImage(File.ReadAllBytes(pathsWithExtension));
         TextureImporter atPath = (TextureImporter)AssetImporter.GetAtPath(pathsWithExtension);
         if (texture2D.height <= atPath.maxTextureSize && texture2D.width <= atPath.maxTextureSize)
         {
             continue;
         }
         this.checklistItem.AddPath(pathsWithExtension);
     }
 }
Ejemplo n.º 16
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);
            }
        }
Ejemplo n.º 17
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>());
        }
Ejemplo n.º 18
0
        public static List <string> GetModelPaths()
        {
            List <string> pathsWithExtensions = ValidatorData.GetPathsWithExtensions(ValidatorData.MODEL_EXTENSIONS, null);
            List <string> strs = new List <string>();

            foreach (string pathsWithExtension in pathsWithExtensions)
            {
                if (!ValidatorData.GetMeshes(ValidatorData.LoadAssetAtPath <GameObject>(pathsWithExtension)).Any <Mesh>() || ValidatorData.HasAnimations(pathsWithExtension))
                {
                    continue;
                }
                strs.Add(pathsWithExtension);
            }
            return(strs);
        }
Ejemplo n.º 19
0
        public override void Scan()
        {
            IEnumerable <string> enumerable = from p in AssetDatabase.GetAllAssetPaths()
                                              where ValidatorData.PathInAssetDir(p)
                                              select p;

            foreach (string path in enumerable)
            {
                GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(path);
                if (gameObject != null && ReferenceScanner.IsMissingReference(gameObject))
                {
                    this.checklistItem.AddPath(path);
                }
            }
        }
Ejemplo n.º 20
0
        private void ScanForMixamo()
        {
            List <string> pathsWithExtensions = ValidatorData.GetPathsWithExtensions(new string[]
            {
                ".fbx"
            }, null);

            foreach (string text in pathsWithExtensions)
            {
                bool flag = ValidatorUtils.IsMixamoFbx(text);
                if (flag)
                {
                    this.mixamoCheck.AddPath(text);
                }
            }
        }
Ejemplo n.º 21
0
        public static List <string> GetModelPaths()
        {
            List <string> pathsWithExtensions = ValidatorData.GetPathsWithExtensions(ValidatorData.MODEL_EXTENSIONS, null);
            List <string> list = new List <string>();

            foreach (string text in pathsWithExtensions)
            {
                GameObject  go     = ValidatorData.LoadAssetAtPath <GameObject>(text);
                List <Mesh> meshes = ValidatorData.GetMeshes(go);
                if (meshes.Any <Mesh>() && !ValidatorData.HasAnimations(text))
                {
                    list.Add(text);
                }
            }
            return(list);
        }
Ejemplo n.º 22
0
        internal static string ToProjectRelativePath(string path)
        {
            path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            string text = Application.dataPath;

            text = text.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            if (path.StartsWith(text) && path.Length > text.Length)
            {
                path = path.Substring(text.Length + 1);
            }
            if (!ValidatorData.PathInAssetDir(path))
            {
                path = Path.Combine("Assets", path);
            }
            return(path);
        }
Ejemplo n.º 23
0
        public override void Scan()
        {
            List <string> pathsWithExtensions = ValidatorData.GetPathsWithExtensions(ValidatorData.TEXTURE_EXTENSIONS, null);

            foreach (string text in pathsWithExtensions)
            {
                Texture2D texture2D = new Texture2D(1, 1);
                ImageConversion.LoadImage(texture2D, File.ReadAllBytes(text));
                TextureImporter textureImporter = AssetImporter.GetAtPath(text) as TextureImporter;
                if (!(textureImporter == null))
                {
                    if (texture2D.height > textureImporter.maxTextureSize || texture2D.width > textureImporter.maxTextureSize)
                    {
                        this.checklistItem.AddPath(text);
                    }
                }
            }
        }
Ejemplo n.º 24
0
        public static List <Mesh> GetMeshes(GameObject go)
        {
            List <Mesh> meshes = new List <Mesh>();

            MeshFilter[]          componentsInChildren     = go.GetComponentsInChildren <MeshFilter>(true);
            SkinnedMeshRenderer[] skinnedMeshRendererArray = go.GetComponentsInChildren <SkinnedMeshRenderer>(true);
            meshes.AddRange(
                from m in (IEnumerable <MeshFilter>) componentsInChildren
                select m.sharedMesh);
            meshes.AddRange(
                from m in (IEnumerable <SkinnedMeshRenderer>) skinnedMeshRendererArray
                select m.sharedMesh);
            meshes = (
                from m in meshes
                where ValidatorData.PathInAssetDir(AssetDatabase.GetAssetPath(m))
                select m).ToList <Mesh>();
            return(meshes);
        }
Ejemplo n.º 25
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>());
        }
Ejemplo n.º 26
0
        private void ScanForAnimations()
        {
            List <string> pathsWithExtensions = ValidatorData.GetPathsWithExtensions(ValidatorData.MODEL_EXTENSIONS, null);

            foreach (string text in pathsWithExtensions)
            {
                List <ModelImporterClipAnimation> list = new List <ModelImporterClipAnimation>();
                ModelImporter modelImporter            = (ModelImporter)AssetImporter.GetAtPath(text);
                list.AddRange(modelImporter.clipAnimations);
                list.AddRange(modelImporter.defaultClipAnimations);
                HashSet <string> hashSet = new HashSet <string>();
                for (int i = 0; i < list.Count; i++)
                {
                    if (!hashSet.Add(list[i].name))
                    {
                        this.animationCheck.AddPath(text);
                        break;
                    }
                }
            }
        }
Ejemplo n.º 27
0
        private void ScanForPrefabs()
        {
            List <string>    pathsWithExtensions = ValidatorData.GetPathsWithExtensions(ValidatorData.PREFAB_EXTENSIONS, null);
            HashSet <string> strs = new HashSet <string>();

            foreach (string pathsWithExtension in pathsWithExtensions)
            {
                GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(pathsWithExtension);
                if (gameObject == null)
                {
                    continue;
                }
                foreach (Mesh mesh in ValidatorData.GetMeshes(gameObject))
                {
                    strs.Add(AssetDatabase.GetAssetPath(mesh));
                }
            }
            List <string> modelPaths = ValidatorData.GetModelPaths();
            List <string> list       = modelPaths.Except <string>(strs, new CustomPathComparer()).ToList <string>();

            this.prefabsCheck.AddPaths(list);
        }
Ejemplo n.º 28
0
        private void ScanForPrefabs()
        {
            List <string>    pathsWithExtensions = ValidatorData.GetPathsWithExtensions(ValidatorData.PREFAB_EXTENSIONS, null);
            HashSet <string> hashSet             = new HashSet <string>();

            foreach (string path in pathsWithExtensions)
            {
                GameObject gameObject = ValidatorData.LoadAssetAtPath <GameObject>(path);
                if (gameObject != null)
                {
                    List <Mesh> meshes = ValidatorData.GetMeshes(gameObject);
                    foreach (Mesh mesh in meshes)
                    {
                        string assetPath = AssetDatabase.GetAssetPath(mesh);
                        hashSet.Add(assetPath);
                    }
                }
            }
            List <string> modelPaths = ValidatorData.GetModelPaths();
            List <string> paths      = modelPaths.Except(hashSet, new CustomPathComparer()).ToList <string>();

            this.prefabsCheck.AddPaths(paths);
        }
Ejemplo n.º 29
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();
            }
        }
Ejemplo n.º 30
0
        private static bool NeedsTransformReset(GameObject go)
        {
            List <Mesh> meshes = ValidatorData.GetMeshes(go);

            return(meshes.Any <Mesh>() && !go.transform.localToWorldMatrix.isIdentity);
        }