void OnGUI_Execute(List <GUIAction> actions) { foreach (var action in actions) { switch (action.kind) { case GUIActionKind.OpenSelectedAsset: OpenAsset(m_SelectedAsset); break; case GUIActionKind.LoadAssetMetaData: m_AssetMetadata = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform); break; case GUIActionKind.LoadAssetReferenceMetaData: m_AssetMetadataReference = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform, referenceFolder); break; case GUIActionKind.BuildReportJob: { m_CurrentJob = action.jobBuilder(); if (m_CurrentJob != null) { m_JobAssets[m_CurrentJob] = action.asset; m_CurrentJob.OnComplete(OnBuildReportJobComplete); } break; } case GUIActionKind.ExportReport: { var assetGUID = ShaderAnalysisUtils.CalculateGUIDFor(action.asset); var report = m_AssetMetadata.GetReport(assetGUID); var tempReportFile = ShaderAnalysisUtils.GetTemporaryReportFile(action.asset, m_CurrentPlatform); var tempReportFileName = ExporterUtilities.ChangeExtensionFor(m_ReportExporterIndex, tempReportFile.FullName); ExporterUtilities.Export(m_ReportExporterIndex, report, tempReportFileName); Application.OpenURL(tempReportFileName); break; } case GUIActionKind.SetAsReference: SetAsReference(m_CurrentPlatform, action.assetGUID, action.report); break; case GUIActionKind.ExportDiffReport: { var diff = ShaderAnalysisUtils.DiffReports(action.report, action.reportReference); var exportFile = ShaderAnalysisUtils.GetTemporaryDiffFile(action.assetGUID, m_CurrentPlatform); var exportReportFileName = ExporterUtilities.ChangeExtensionFor(m_ReportExporterIndex, exportFile.FullName); ExporterUtilities.ExportDiff(m_ReportDiffExporterIndex, diff, exportReportFileName); Application.OpenURL(exportReportFileName); break; } } } }
void OnGUI_BuildReportToolbar(List <GUIAction> actions, Func <IAsyncJob> buildReportJob, Object asset, PlatformJob capability) { if (m_AssetMetadata == null) { return; } var assetGUID = ShaderAnalysisUtils.CalculateGUIDFor(asset); var report = m_AssetMetadata.GetReport(assetGUID); GUILayout.BeginHorizontal(EditorStyles.toolbar); { EditorGUILayout.LabelField("Reporting", EditorStyles.whiteLargeLabel, GUILayout.Width(75)); GUI.enabled = EditorShaderTools.DoesPlatformSupport(m_CurrentPlatform, capability); if (GUILayout.Button(EditorGUIUtility.TrIconContent("PlayButton On", "Build Report"), EditorStyles.toolbarButton, GUILayout.Width(k_IconSize))) { actions.Add(new GUIAction(GUIActionKind.BuildReportJob, buildReportJob, asset)); } m_BuildReportFeature = (BuildReportFeature)EditorGUILayout.EnumFlagsField(m_BuildReportFeature, GUILayout.Width(80)); GUILayout.Space(k_HorizontalSpacing); var genDir = ShaderAnalysisUtils.GetTemporaryDirectory(asset, m_CurrentPlatform); GUI.enabled = genDir.Exists; if (GUILayout.Button(EditorGUIUtility.TrIconContent("Project", "Open Temp Dir"), EditorStyles.toolbarButton, GUILayout.Width(k_IconSize))) { Application.OpenURL(genDir.FullName); } GUILayout.Space(k_HorizontalSpacing); GUI.enabled = report != null && ExporterUtilities.IsValid(m_ReportExporterIndex); if (GUILayout.Button(EditorGUIUtility.TrIconContent("SceneLoadOut", "Export to"), EditorStyles.toolbarButton, GUILayout.Width(k_IconSize))) { actions.Add(new GUIAction(GUIActionKind.ExportReport, asset)); } GUI.enabled = true; m_ReportExporterIndex = (ReportExporterIndex)EditorGUILayout.Popup((int)m_ReportExporterIndex, ExporterUtilities.ReportExporterNames, GUILayout.Width(k_ExporterSize)); } GUILayout.EndHorizontal(); GUI.enabled = true; }
void OnGUI_DiffReportToolbar(List <GUIAction> actions, Object asset) { if (m_AssetMetadata == null) { return; } var assetGUID = ShaderAnalysisUtils.CalculateGUIDFor(asset); var report = m_AssetMetadata.GetReport(assetGUID); var reportReference = m_AssetMetadataReference != null?m_AssetMetadataReference.GetReport(assetGUID) : null; GUILayout.BeginHorizontal(EditorStyles.toolbar); { EditorGUILayout.LabelField("Diff", EditorStyles.whiteLargeLabel, GUILayout.Width(55)); GUI.enabled = report != null; if (GUILayout.Button(EditorGUIUtility.TrIconContent("SceneLoadIn", "Set as reference"), EditorStyles.toolbarButton, GUILayout.Width(k_IconSize))) { actions.Add(new GUIAction(GUIActionKind.SetAsReference, assetGUID, report)); } GUILayout.Space(k_HorizontalSpacing); GUI.enabled = report != null && reportReference != null && ExporterUtilities.IsValid(m_ReportDiffExporterIndex); if (GUILayout.Button(EditorGUIUtility.TrIconContent("SceneLoadOut", "Export diff to"), EditorStyles.toolbarButton, GUILayout.Width(k_IconSize))) { actions.Add(new GUIAction(GUIActionKind.ExportDiffReport, report, reportReference, assetGUID)); } GUI.enabled = true; m_ReportDiffExporterIndex = (ReportDiffExporterIndex)EditorGUILayout.Popup((int)m_ReportDiffExporterIndex, ExporterUtilities.ReportDiffExporterNames, GUILayout.Width(k_ExporterSize)); } GUILayout.EndHorizontal(); GUI.enabled = true; }