Esempio n. 1
0
            public void CopyMeshes(MeshFilter meshFilter)
            {
                var mesh = meshFilter.sharedMesh;

                reduceMeshName(mesh);
                if (
                    meshAssets.ContainsKey(mesh.name) &&
                    meshAssets[mesh.name].ContainsKey(mesh.vertexCount)
                    )
                {
                    return;
                }
                // IMPORTANT: Default meshes may be in use and are not in Assets path
                if (!AssetDatabase.GetAssetPath(mesh).StartsWith("Assets/"))
                {
                    return;
                }
                expandMeshName(mesh);
                var copyMesh = EP.CopyAssetToPath(mesh, meshPath.Substring("Assets/".Length), ".asset");

                reduceMeshName(mesh);
                if (!meshAssets.ContainsKey(mesh.name))
                {
                    meshAssets.Add(mesh.name, new Dictionary <int, Mesh>());
                }
                meshAssets[mesh.name].Add(mesh.vertexCount, copyMesh);
            }
Esempio n. 2
0
            public void CopyMaterials(Renderer renderer)
            {
                var sharedMaterials = renderer.sharedMaterials;

                for (var m = 0; m < sharedMaterials.Length; ++m)
                {
                    var material = sharedMaterials[m];
                    if (!material)
                    {
                        continue;
                    }
                    if (materialAssets.ContainsKey(material.name))
                    {
                        continue;
                    }
                    // IMPORTANT: Default materials may be in use and are not in Assets path
                    if (!AssetDatabase.GetAssetPath(material).StartsWith("Assets/"))
                    {
                        continue;
                    }
                    var copyMaterial = EP.CopyAssetToPath(material, materialPath.Substring("Assets/".Length), ".mat");
                    materialAssets.Add(material.name, copyMaterial);
                }
            }
Esempio n. 3
0
            public void CopyTextures(Material material)
            {
                if (material.shader.name != "Standard")
                {
                    return;
                }
                var shaderTextures = GetStandardMaterialTextures(material);

                foreach (var shaderTexture in shaderTextures)
                {
                    var texture = shaderTexture.Value;
                    if (textureAssets.ContainsKey(texture.name))
                    {
                        continue;
                    }
                    // IMPORTANT: Default textures may be in use and are not in Assets path
                    if (!AssetDatabase.GetAssetPath(texture).StartsWith("Assets/"))
                    {
                        continue;
                    }
                    var copyTexture = EP.CopyAssetToPath(texture, texturePath.Substring("Assets/".Length));
                    textureAssets.Add(texture.name, copyTexture);
                }
            }