Example #1
0
        private static void CollectDetailsForPrefab(List <AssetProperty> props, GameObject prefab)
        {
            var hierarchy = EditorUtility.CollectDeepHierarchy(new[] { prefab });

            props.Add(AssetProperty.Create("GameObjects", hierarchy.Count(x => x is GameObject)));
            props.Add(AssetProperty.Create("Components", hierarchy.Count(x => x is Component)));
        }
Example #2
0
        private static void CollectDetailsForMaterial(List <AssetProperty> props, Material material)
        {
            var keywords = material.shaderKeywords;

            props.Add(AssetProperty.Create("KeywordsCount", keywords.Length));
            props.Add(AssetProperty.Create("Keywords", string.Join(", ", keywords)));
        }
Example #3
0
 private static void CollectDetailsForTexture2D(List <AssetProperty> props, Texture2D texture)
 {
     props.Add(AssetProperty.Create("Format", texture.format));
     props.Add(AssetProperty.Create("Mipmaps", texture.mipmapCount));
     props.Add(AssetProperty.Create("Width", texture.width));
     props.Add(AssetProperty.Create("Height", texture.height));
     props.Add(AssetProperty.Create("NPOT", !Mathf.IsPowerOfTwo(texture.width) || !Mathf.IsPowerOfTwo(texture.height)));
 }
Example #4
0
 private static void CollectDetailsForAudioClip(List <AssetProperty> props, AudioClip audioClip, string path)
 {
     props.Add(AssetProperty.Create("Frequency", audioClip.frequency));
     props.Add(AssetProperty.Create("Length", audioClip.length));
     props.Add(AssetProperty.Create("Channels", audioClip.channels));
     props.Add(AssetProperty.Create("LoadType", UnityVersionAgnostic.GetAudioClipLoadType(audioClip, path)));
     props.Add(AssetProperty.Create("Format", UnityVersionAgnostic.GetAudioClipFormat(audioClip, path)));
     props.Add(AssetProperty.Create("LoadInBackground", audioClip.loadInBackground));
     props.Add(AssetProperty.Create("Preload", audioClip.preloadAudioData));
 }
Example #5
0
        private static void CollectDetailsModelPrefab(List <AssetProperty> props, GameObject prefab, ModelImporter importer)
        {
            int totalVertices    = 0;
            int totalBlendShapes = 0;
            int totalPrimitives  = 0;

            HashSet <string> channels = null;

            if (IsGetUsedChannelsSupported)
            {
                channels = new HashSet <string>();
            }

            foreach (var mesh in AssetDatabase.LoadAllAssetsAtPath(importer.assetPath).OfType <Mesh>())
            {
                totalVertices    += mesh.vertexCount;
                totalBlendShapes += mesh.blendShapeCount;
                totalPrimitives  += GetPrimitiveCount(mesh);

                if (channels != null)
                {
                    foreach (var channel in GetUsedChannelsSanitized(mesh))
                    {
                        channels.Add(channel);
                    }
                }
            }

            if (importer.IsMeshOptimized() != null)
            {
                props.Add(AssetProperty.Create("Optimize", importer.IsMeshOptimized()));
            }
            if (importer.AreMeshVerticesOptimised() != null)
            {
                props.Add(AssetProperty.Create("OptimizeVertices", importer.AreMeshVerticesOptimised()));
            }
            if (importer.AreMeshPolygonsOptimised() != null)
            {
                props.Add(AssetProperty.Create("OptimizePolygons", importer.AreMeshPolygonsOptimised()));
            }

            props.Add(AssetProperty.Create("Vertices", totalVertices));
            props.Add(AssetProperty.Create("Triangles", totalPrimitives));
            props.Add(AssetProperty.Create("BlendShapes", totalBlendShapes));
            props.Add(AssetProperty.Create("Animations", importer.clipAnimations.Length));

            if (channels != null)
            {
                props.Add(AssetProperty.Create("VertexFormat", string.Join(",", channels.OrderBy(x => x).ToArray())));
            }
        }
Example #6
0
        private void CollectDetailsForMonoScript(List <AssetProperty> props, MonoScript asset, string assetPath)
        {
            string className = string.Empty;

            var classType = asset.GetClass();

            if (classType != null && classType.IsSubclassOf(typeof(UnityEngine.Object)))
            {
                className = classType.FullName;
                m_scriptsToLookReferencesTo.Add(assetPath);
            }

            props.Add(AssetProperty.Create("ScriptClass", className));
        }
Example #7
0
        public AssetProperty[] CollectForCurrentScene(GameObject[] sceneRoots)
        {
            var allObjects      = EditorUtility.CollectDeepHierarchy(sceneRoots);
            var gameObjectCount = allObjects.Count(x => x is GameObject);
            var componentsCount = allObjects.Count(x => x is Component);

            List <AssetProperty> props = new List <AssetProperty>();

            props.Add(AssetProperty.Create("GameObjects", gameObjectCount));
            props.Add(AssetProperty.Create("Components", componentsCount));

            int staticBatching, dynamicBatching;

            GetBatchingForPlatform(EditorUserBuildSettings.activeBuildTarget, out staticBatching, out dynamicBatching);

            if (staticBatching != 0)
            {
                HashSet <Mesh> staticMeshes = new HashSet <Mesh>();
                foreach (var mf in allObjects.OfType <MeshFilter>())
                {
                    var sharedMesh = mf.sharedMesh;
                    if (sharedMesh == null)
                    {
                        continue;
                    }

                    var meshRenderer = mf.GetComponent <MeshRenderer>();
                    if (meshRenderer == null)
                    {
                        continue;
                    }

                    if (EditorUtility.IsPersistent(sharedMesh))
                    {
                        continue;
                    }

                    if (sharedMesh.name.StartsWith("Combined Mesh (root: "))
                    {
                        staticMeshes.Add(sharedMesh);
                    }
                }

                var combinedMeshVertirces = staticMeshes.Sum(x => x.vertexCount);
                var primitives            = staticMeshes.Sum(x => GetPrimitiveCount(x));

                props.Add(AssetProperty.Create("Vertices", combinedMeshVertirces));
                props.Add(AssetProperty.Create("Triangles", primitives));

                if (IsGetUsedChannelsSupported)
                {
                    var channels = staticMeshes.SelectMany(x => GetUsedChannelsSanitized(x)).Distinct().OrderBy(x => x).ToArray();
                    props.Add(AssetProperty.Create("VertexFormat", string.Join(",", channels.ToArray())));
                }

                var lightmapsCount = LightmapSettings.lightmaps.Select(x => (x.GetLight() != null ? 1 : 0) + (x.GetDirectional() != null ? 1 : 0)).Sum();
                props.Add(AssetProperty.Create("LightmapTextures", lightmapsCount));
            }

            return(props.ToArray());
        }