示例#1
0
        public void OnPreprocessBuild(BuildReport report)
        {
            if ((report.summary.options & BuildOptions.IncludeTestAssemblies) != 0)
            {
                RecordedPlaybackEditorUtils.CreateDirectoryIfNotExists(resourcesPath);

                foreach (var testdata in RecordedTesting.RecordedTesting.GetAllRecordedTests())
                {
                    string sourceFromEditor = Path.Combine(Application.dataPath, testdata.recording);
                    string destInResources  = Path.Combine(resourcesPath, testdata.recording);

                    if (File.Exists(sourceFromEditor))
                    {
                        RecordedPlaybackEditorUtils.CreateDirectoryIfNotExists(Path.GetDirectoryName(destInResources));
                        RecordedPlaybackEditorUtils.MarkFilesAsCreated(RecordedPlaybackPersistentData.CopyRecordingFile(sourceFromEditor, destInResources));
                    }
                    else
                    {
                        Debug.LogError($"file {sourceFromEditor} doesn't exist");
                    }
                }

                var runs = AssetDatabase.FindAssets("t:AutomatedRun");
                foreach (var runGuid in runs)
                {
                    string runPath          = AssetDatabase.GUIDToAssetPath(runGuid);
                    string sourceFromEditor = Path.Combine(runPath);
                    string destInResources  = Path.Combine(resourcesPath, "AutomatedRuns", Path.GetFileName(runPath));

                    if (File.Exists(sourceFromEditor))
                    {
                        RecordedPlaybackEditorUtils.CreateDirectoryIfNotExists(Path.GetDirectoryName(destInResources));
                        File.Copy(sourceFromEditor, destInResources);
                        RecordedPlaybackEditorUtils.MarkFileAsCreated(destInResources);
                        Debug.Log($"Copied AutomatedRun file from {sourceFromEditor} to {destInResources}");
                    }
                    else
                    {
                        Debug.LogError($"file {sourceFromEditor} doesn't exist");
                    }
                }
            }
            ClearFilesOnBuildCompletion(report);
        }
        private static string FormatRecording(string recordingName, string filePath)
        {
            var currRecording = RecordingInputModule.InputModuleRecordingData.FromFile(filePath);

            if (currRecording.recordings.Count > 0)
            {
                // create temporary file that copies original
                Debug.Log($"extractRecordingsFromComposite: {recordingName} {filePath}");
                var tempFilePath = $"{AutomatedQARuntimeSettings.RecordingFolderNameWithAssetPath}/Temp/{recordingName}";
                var segmentDir   = Path.GetDirectoryName(filePath) ?? "";
                currRecording.touchData = currRecording.GetAllTouchData(segmentDir: segmentDir);
                currRecording.recordings.Clear();
                RecordedPlaybackEditorUtils.CreateDirectoryIfNotExists(Path.GetDirectoryName(tempFilePath));
                currRecording.SaveToFile(tempFilePath);
                RecordedPlaybackEditorUtils.MarkFileAsCreated(tempFilePath);

                return(tempFilePath);
            }

            return(filePath);
        }