public void ExportHVRAssetClipData(string buildExecutablePath) { CleanHRVAssetClipData(buildExecutablePath); string buildDirectoryPath = GetBuildDirectoryFromBuildPath(buildExecutablePath); List <HvrAsset> clipsToExport = GetHvrAssetsInBuild(); Debug.Log("[HVR] Exporting " + clipsToExport.Count + " HVRAsset Data folder"); List <string[]> copyMappings = new List <string[]>(); foreach (HvrAsset clipToExport in clipsToExport) { DirectoryInfo assetDataDir = GetAssetDataDir(clipToExport); FileInfo assetDataFile = GetAssetDataFile(clipToExport); if (assetDataDir == null & assetDataFile == null) { string assetDataName; if (clipToExport.data == null) { assetDataName = "null"; } else { assetDataName = clipToExport.data.name; } EditorUtility.DisplayDialog("Invalid HVR Asset", "HVR asset '" + clipToExport.name + "' has an invalid data folder attribute. This attribute should be pointing to a valid project folder, but is instead pointing to: '" + assetDataName + "'.\n\nThis HVR asset has not been packaged with your build. This may result in missing HVR actors in your built application.", "Continue"); } else if (assetDataFile != null) { string destinationFile = buildDirectoryPath + "8i/" + clipToExport.uniqueID + "/" + assetDataFile.Name; copyMappings.Add(new string[] { assetDataFile.FullName, destinationFile }); } else { List <string> assetFiles = GetAssetFiles(assetDataDir); foreach (string assetFile in assetFiles) { string relativeFileName = assetFile.Replace(assetDataDir.FullName, ""); string destinationFile = buildDirectoryPath + "8i/" + clipToExport.uniqueID + "/" + relativeFileName; copyMappings.Add(new string[] { assetFile, destinationFile }); } } } fileCopier = new FileCopier(); fileCopier.Start(copyMappings.ToArray(), true); }
public void ExportAssetData(List <string> guids, string directory) { if (Directory.Exists(directory)) { Directory.Delete(directory, true); } Directory.CreateDirectory(directory); HashSet <string[]> copyMappings = new HashSet <string[]>(); for (int i = 0; i < guids.Count; i++) { string dataGuid = guids[i]; string dataPath = EditorHelper.GetAssetPathFromGUID(dataGuid); // Skip if data does not exist if (string.IsNullOrEmpty(dataPath)) { continue; } if (Application.platform != RuntimePlatform.OSXEditor #if UNITY_EDITOR_LINUX && Application.platform != RuntimePlatform.LinuxEditor #endif ) { // Just in case of different file systems returning different results dataPath = dataPath.Replace("/", "\\"); dataPath = dataPath.Replace(@"\", "\\"); } FileAttributes fileAttr = File.GetAttributes(dataPath); if ((fileAttr & FileAttributes.Directory) == FileAttributes.Directory) { DirectoryInfo dataFolder = new DirectoryInfo(dataPath); FileInfo[] files = dataFolder.GetFiles(); for (int j = 0; j < files.Length; j++) { // Skip any meta files as they aren't wanted if (files[j].FullName.EndsWith(".meta")) { continue; } string path = Path.Combine(directory, dataGuid); path = Path.Combine(path, files[j].Name); copyMappings.Add(new string[] { files[j].FullName, path }); } } else { FileInfo sourceFile = new FileInfo(dataPath); FileInfo destinationFile = new FileInfo(Path.Combine(directory, dataGuid) + sourceFile.Extension); copyMappings.Add(new string[] { sourceFile.FullName, destinationFile.FullName }); } } fileCopier = new FileCopier(); fileCopier.Start(copyMappings.ToArray(), true); }