public void CanWriteCustomData() { string usdFile = System.IO.Path.Combine(UnityEngine.Application.dataPath, "sceneFile.usda"); filesToDelete.Add(usdFile); // Populate Values. var value = new MyCustomData(); value.aString = "IT'S ALIIIIIIIIIIIIIVE!"; value.anArrayOfInts = new int[] { 1, 2, 3, 4 }; value.aBoundingBox = new UnityEngine.Bounds(); // Writing the value. var scene = Scene.Create(usdFile); scene.Time = 1.0; scene.Write("/someValue", value); Debug.Log(scene.Stage.GetRootLayer().ExportToString()); scene.Save(); scene.Close(); Assert.IsTrue(File.Exists(usdFile)); // Reading the value. Debug.Log(usdFile); var newValue = new MyCustomData(); scene = Scene.Open(usdFile); scene.Time = 1.0; scene.Read("/someValue", newValue); Assert.AreEqual(value.aString, newValue.aString); scene.Close(); }
public void CanWriteCustomData() { // Populate Values. var value = new MyCustomData(); value.aString = "IT'S ALIIIIIIIIIIIIIVE!"; value.anArrayOfInts = new int[] { 1, 2, 3, 4 }; value.aBoundingBox = new UnityEngine.Bounds(); // Writing the value. string usdFile = CreateTmpUsdFile("sceneFile.usda"); var scene = ImportHelpers.InitForOpen(usdFile); scene.Time = 1.0; scene.Write("/someValue", value); Debug.Log(scene.Stage.GetRootLayer().ExportToString()); scene.Save(); scene.Close(); Assert.IsTrue(File.Exists(usdFile), "File not found."); // Reading the value. Debug.Log(usdFile); var newValue = new MyCustomData(); scene = Scene.Open(usdFile); scene.Time = 1.0; scene.Read("/someValue", newValue); Assert.AreEqual(value.aString, newValue.aString, "Serialized data don't match the original data."); scene.Close(); }