static void SetAsReference(BuildTarget buildTarget, string assetGUID, ShaderBuildReport report)
        {
            var metadatas = ShaderAnalysisUtils.LoadAssetMetadatasFor(buildTarget, referenceFolder);

            metadatas.SetReport(assetGUID, report);
            ShaderAnalysisUtils.SaveAssetMetadata(metadatas, referenceFolder);
        }
        void OnEnable()
        {
            m_CurrentPlatform        = EditorUserBuildSettings.activeBuildTarget;
            m_AssetMetadata          = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform);
            m_AssetMetadataReference = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform, referenceFolder);

            if (m_SupportedPlatformNames == null)
            {
                m_SupportedPlatformNames = EditorShaderTools.SupportedBuildTargets.Select(s => s.ToString()).ToArray();
                m_SupportedPlatforms     = EditorShaderTools.SupportedBuildTargets.ToArray();
            }

            m_GUI = NOOPGUI;
            if (m_SelectedAsset != null && !m_SelectedAsset.Equals(null))
            {
                OpenAsset(m_SelectedAsset);
            }
            if (m_SelectedPlatformIndex >= 0 && m_SelectedPlatformIndex < m_SupportedPlatforms.Length)
            {
                m_CurrentPlatform = m_SupportedPlatforms[m_SelectedPlatformIndex];
                m_AssetMetadata   = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform);
            }
            if (!string.IsNullOrEmpty(referenceSourceFolderPath) && Directory.Exists(referenceSourceFolderPath) && m_CurrentPlatform != BuildTarget.NoTarget)
            {
                m_AssetMetadataReference = ShaderAnalysisUtils.LoadAssetMetadatasFor(m_CurrentPlatform, referenceFolder);
            }
        }
        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 OnBuildReportJobComplete(IAsyncJob obj)
        {
            var asset = m_JobAssets[obj];

            m_JobAssets.Remove(obj);

            var job = obj as AsyncBuildReportJob;

            Assert.IsNotNull(job);

            ShaderBuildReport report = null;

            if (job.IsComplete() &&
                job.hasReport &&
                (report = job.builtReport) != null)
            {
                var metadata  = ShaderAnalysisUtils.LoadAssetMetadatasFor(job.target);
                var assetGUID = ShaderAnalysisUtils.CalculateGUIDFor(asset);
                metadata.SetReport(assetGUID, report);
                ShaderAnalysisUtils.SaveAssetMetadata(metadata);
            }
        }