Example #1
0
        private static void CopyDaeTextureToExportDestination(string prefabPath, string newFolderLocation)
        {
            //Get material from Collada prefab
            Material material = AssetDatabase.LoadAssetAtPath <Material>(prefabPath);

            if (material.mainTexture == null)
            {
                return;
            }

            //Get relative subfolder where texture is, compared to the DAE file.
            string commonFolder     = Path.GetDirectoryName(prefabPath).SetSeparatorChar();
            string texturePath      = AssetDatabase.GetAssetPath(material.mainTexture).SetSeparatorChar();
            string relativeLocation = "";

            if (texturePath.Contains(commonFolder))
            {
                relativeLocation = texturePath.Substring(commonFolder.Length + 1);
            }
            string newTexturePath = Path.Combine(newFolderLocation, relativeLocation);

            Directory.CreateDirectory(Path.GetDirectoryName(newTexturePath));

            CopyFileToNewLocation(UrdfAssetPathHandler.GetFullAssetPath(texturePath), newTexturePath);
        }
Example #2
0
        private static Link.Visual.Material.Texture ExportTextureData(Texture texture)
        {
            string oldTexturePath = UrdfAssetPathHandler.GetFullAssetPath(AssetDatabase.GetAssetPath(texture));
            string newTexturePath = UrdfExportPathHandler.GetNewResourcePath(Path.GetFileName(oldTexturePath));

            if (oldTexturePath != newTexturePath)
            {
                File.Copy(oldTexturePath, newTexturePath, true);
            }

            string packagePath = UrdfExportPathHandler.GetPackagePathForResource(newTexturePath);

            return(new Link.Visual.Material.Texture(packagePath));
        }
Example #3
0
        private static string CopyMeshToExportDestination(string prefabPath)
        {
            string newPrefabPath = UrdfExportPathHandler.GetNewMeshPath(Path.GetFileName(prefabPath));

            if (Path.GetExtension(prefabPath)?.ToLower() == ".dae")
            {
                CopyDaeTextureToExportDestination(prefabPath, Path.GetDirectoryName(newPrefabPath));
            }

            prefabPath = UrdfAssetPathHandler.GetFullAssetPath(prefabPath);

            CopyFileToNewLocation(prefabPath, newPrefabPath);

            return(newPrefabPath);
        }