public void OnGUI() { InitStyles(); Vector2 oldIconSize = EditorGUIUtility.GetIconSize(); EditorGUIUtility.SetIconSize(Content.k_IconSize); var activeBuildTargetGroup = selectedBuildTargetGroup; if (activeBuildTargetGroup == BuildTargetGroup.Unknown) { activeBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); } OpenXRProjectValidation.GetCurrentValidationIssues(_failures, activeBuildTargetGroup); EditorGUILayout.BeginVertical(); bool fixAllSelected = DrawIssuesAndFixAll(); if (EditorApplication.isPlaying) { GUILayout.Space(Content.k_Space); GUILayout.Label(Content.k_PlayMode); } EditorGUILayout.Space(); bool anyFixApplied = false; if (_failures.Count > 0) { anyFixApplied = DrawIssuesList(); } EditorGUILayout.EndVertical(); EditorGUIUtility.SetIconSize(oldIconSize); ActionAnyFixes(fixAllSelected, anyFixApplied, activeBuildTargetGroup); }
void ActionAnyFixes(bool fixAllSelected, bool anyFixApplied, BuildTargetGroup activeBuildTargetGroup) { bool fixApplied = anyFixApplied; if ((_failures.Any(s => s.fixIt != null) && fixAllSelected) || _fixAllStack.Count > 0) { // Copy the failures list if there are any that we need to fix if (_fixAllStack.Count == 0 && _failures.Count > 0) { _fixAllStack = _failures.ToList(); } // If we have any failures that we're fixing .. if (_fixAllStack.Count > 0) { // Wait a few frames between fixes - some are deferred ++_framesBetweenFixesCounter; if (_framesBetweenFixesCounter >= desiredFramesBetweenFixes) { // Do the fix, remove from the fixall stack, reset counter. _fixAllStack[0].fixIt?.Invoke(); _fixAllStack.Remove(_fixAllStack[0]); _framesBetweenFixesCounter = 0; } } // Request that come in here again next frame to fix the rest of the errors if (_fixAllStack.Count > 0) { Repaint(); } fixApplied = true; } if (fixApplied) { OpenXRProjectValidation.GetCurrentValidationIssues(_failures, activeBuildTargetGroup); } }
private void UpdateIssues(bool force = false) { var interval = EditorWindow.focusedWindow == this ? k_UpdateInterval : k_BackgroundUpdateInterval; if (!s_Dirty && !force && EditorApplication.timeSinceStartup - _lastUpdate < interval) { return; } s_Dirty = false; if (_fixAllStack.Count > 0) { _fixAllStack[0].fixIt?.Invoke(); _fixAllStack.RemoveAt(0); } var activeBuildTargetGroup = s_SelectedBuildTargetGroup; if (activeBuildTargetGroup == BuildTargetGroup.Unknown) { activeBuildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget); } var failureCount = _failures.Count; OpenXRProjectValidation.GetCurrentValidationIssues(_failures, activeBuildTargetGroup); // Repaint the window if the failure count has changed if (_failures.Count > 0 || failureCount > 0) { Repaint(); } _lastUpdate = EditorApplication.timeSinceStartup; }