public void InitForSave_ValidPath() { var filePath = System.IO.Path.Combine(Application.dataPath, "dummyUsd.usd"); m_filesToDelete.Add(filePath); var scene = ExportHelpers.InitForSave(filePath); Assert.IsNotNull(scene); Assert.IsNotNull(scene.Stage); scene.Close(); }
protected override void SessionCreated(RecordingSession session) { base.SessionCreated(session); InitUsd.Initialize(); var outputFile = Settings.FileNameGenerator.BuildAbsolutePath(session); if (Settings.ExportFormat == UsdRecorderSettings.Format.USDZ) // FIXME Support USDz { try { currentDir = Directory.GetCurrentDirectory(); // Setup a temporary directory to export the wanted USD file and zip it. var tmpDirPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); usdzTemporaryDir = Directory.CreateDirectory(tmpDirPath); // Get the usd file name to export and the usdz file name of the archive. usdcFileName = Path.GetFileNameWithoutExtension(outputFile) + ".usdc"; usdzFileName = Path.GetFileName(outputFile); var fi = new FileInfo(outputFile); usdzFilePath = fi.FullName; // Set the current working directory to the tmp directory to export with relative paths. Directory.SetCurrentDirectory(tmpDirPath); outputFile = Path.Combine(tmpDirPath, usdcFileName); } finally { Directory.SetCurrentDirectory(currentDir); } } try { context = new ExportContext { scene = ExportHelpers.InitForSave(outputFile) }; } catch (Exception) { throw new InvalidOperationException($"The file is already open in Unity. Please close all references to it and try again: {outputFile}"); } context.scene.FrameRate = Settings.FrameRate; // Variable framerate support ? context.scene.Stage.SetInterpolationType(Settings.InterpolationType); // User Option context.basisTransform = Settings.BasisTransformation; context.activePolicy = Settings.ActivePolicy; context.exportMaterials = Settings.ExportMaterials; context.scale = Settings.Scale; context.scene.StartTime = 0; // Absolute vs relative Time // Export the "default" frame, that is, all data which doesn't vary over time. context.scene.Time = null; Input.Context = context; }
public void InitForSave_NullFile() { var scene = ExportHelpers.InitForSave(null); Assert.IsNull(scene); }
public void InitForSave_EmptyFile() { var scene = ExportHelpers.InitForSave(""); Assert.IsNull(scene); }