Exemplo n.º 1
0
        public static MeshValues operator +(MeshValues a, MeshValues b)
        {
            MeshValues value = new MeshValues();

            value.vertCount      = a.vertCount + b.vertCount;
            value.triangles      = a.triangles + b.triangles;
            value.memory         = a.memory + b.memory;
            value.exist_normals  = a.exist_normals || b.exist_normals;
            value.exist_tangents = a.exist_tangents || b.exist_tangents;
            value.exist_colors   = a.exist_colors || b.exist_colors;
            value.exist_uv[0]    = a.exist_uv[0] || b.exist_uv[0];
            value.exist_uv[1]    = a.exist_uv[1] || b.exist_uv[1];
            value.exist_uv[2]    = a.exist_uv[2] || b.exist_uv[2];
            value.exist_uv[3]    = a.exist_uv[3] || b.exist_uv[3];
            value.isRead         = a.isRead || b.isRead;
            return(value);
        }
Exemplo n.º 2
0
        public void RefleshProps()
        {
            childList     = new List <MeshValues>();
            rootMeshValue = new MeshValues();

            if (!isSkin)
            {
                List <MeshFilter> filters = new List <MeshFilter>();
                filters.AddRange(rootObj.GetComponentsInChildren <MeshFilter>());
                for (int i = filters.Count - 1; i >= 0; i--)
                {
                    if (filters[i].sharedMesh == null)
                    {
                        filters.RemoveAt(i);
                    }
                }
                for (int i = 1; i < filters.Count; i++)
                {
                    for (int j = 0; j < filters.Count - i; j++)
                    {
                        if (filters[j].sharedMesh.vertexCount < filters[j + 1].sharedMesh.vertexCount)
                        {
                            MeshFilter temp = filters[j];
                            filters[j]     = filters[j + 1];
                            filters[j + 1] = temp;
                        }
                    }
                }

                if (isAsset)
                {
                    assetPath = AssetDatabase.GetAssetPath(filters[0].sharedMesh);
                    name      = assetPath.Substring(assetPath.LastIndexOf('/') + 1);
                }
                else
                {
                    name = filters[0].sharedMesh.name + "_InsID=" + filters[0].sharedMesh.GetInstanceID();
                }
                rootMeshValue.parentName = name;
                for (int i = 0; i < filters.Count; i++)
                {
                    if (filters[i].sharedMesh != null)
                    {
                        MeshValues value = new MeshValues(filters[i].sharedMesh);
                        value.parentName = name;
                        childList.Add(value);
                        rootMeshValue += value;
                    }
                }
                if (childList.Count == 1)
                {
                    rootMeshValue.mesh = filters[0].sharedMesh;
                }
                isGroup = childList.Count > 1;
            }
            else
            {
                List <SkinnedMeshRenderer> skins = new List <SkinnedMeshRenderer>();
                skins.AddRange(rootObj.GetComponentsInChildren <SkinnedMeshRenderer>());
                for (int i = skins.Count - 1; i >= 0; i--)
                {
                    if (skins[i].sharedMesh == null)
                    {
                        skins.RemoveAt(i);
                    }
                }
                for (int i = 1; i < skins.Count; i++)
                {
                    for (int j = 0; j < skins.Count - i; j++)
                    {
                        if (skins[j].sharedMesh.vertexCount < skins[j + 1].sharedMesh.vertexCount)
                        {
                            SkinnedMeshRenderer temp = skins[j];
                            skins[j]     = skins[j + 1];
                            skins[j + 1] = temp;
                        }
                    }
                }

                if (isAsset)
                {
                    assetPath = AssetDatabase.GetAssetPath(skins[0].sharedMesh);
                    name      = assetPath.Substring(assetPath.LastIndexOf('/') + 1);
                }
                else
                {
                    name = skins[0].sharedMesh.name + "_InsID=" + skins[0].sharedMesh.GetInstanceID();
                }
                rootMeshValue.parentName = name;
                for (int i = 0; i < skins.Count; i++)
                {
                    if (skins[i].sharedMesh != null)
                    {
                        MeshValues value = new MeshValues(skins[i].sharedMesh);
                        value.parentName = name;
                        childList.Add(value);
                        rootMeshValue += value;
                    }
                }
                if (childList.Count == 1)
                {
                    rootMeshValue.mesh = skins[0].sharedMesh;
                }
                isGroup = childList.Count > 1;
            }
        }