public void OnGUI() { if (asset == null) { return; } if (asset.isDirty) { RefreshEditors(); asset.isDirty = false; } bool isEditable = !VersionControl.Provider.isActive || AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.UseCachedIfPossible); using (new EditorGUI.DisabledScope(!isEditable)) { // Component list for (int i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; string title = editor.GetDisplayTitle(); int id = i; // Needed for closure capture below CoreEditorUtils.DrawSplitter(); bool displayContent = CoreEditorUtils.DrawHeaderToggle( title, editor.baseProperty, editor.activeProperty, pos => OnContextClick(pos, editor.target, id) ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) editor.OnInternalInspectorGUI(); } } if (m_Editors.Count > 0) { CoreEditorUtils.DrawSplitter(); } else { EditorGUILayout.HelpBox("This Volume Profile contains no overrides.", MessageType.Info); } EditorGUILayout.Space(); using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(EditorGUIUtility.TrTextContent("Add Override"), EditorStyles.miniButton)) { var r = hscope.rect; var pos = new Vector2(r.x + r.width / 2f, r.yMax + 18f); FilterWindow.Show(pos, new VolumeComponentProvider(asset, this)); } } } }
/// <summary> /// Draws the editor. /// </summary> public void OnGUI() { if (asset == null) { return; } // Even if the asset is not dirty, the list of component may have been changed by another inspector. // In this case, only the hash will tell us that we need to refresh. if (asset.isDirty || asset.GetComponentListHashCode() != m_CurrentHashCode) { RefreshEditors(); m_CurrentHashCode = asset.GetComponentListHashCode(); asset.isDirty = false; } bool isEditable = !VersionControl.Provider.isActive || AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.UseCachedIfPossible); using (new EditorGUI.DisabledScope(!isEditable)) { // Component list for (int i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; var title = editor.GetDisplayTitle(); int id = i; // Needed for closure capture below m_EditorDocumentationURLs.TryGetValue(editor.target.GetType(), out var documentationURL); CoreEditorUtils.DrawSplitter(); bool displayContent = CoreEditorUtils.DrawHeaderToggle( title, editor.baseProperty, editor.activeProperty, pos => OnContextClick(pos, editor, id), editor.hasAdditionalProperties ? () => editor.showAdditionalProperties : (Func <bool>)null, () => editor.showAdditionalProperties ^= true, documentationURL ); if (displayContent) { using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) editor.OnInternalInspectorGUI(); } } if (m_Editors.Count > 0) { CoreEditorUtils.DrawSplitter(); } else { EditorGUILayout.HelpBox("This Volume Profile contains no overrides.", MessageType.Info); } EditorGUILayout.Space(); using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(EditorGUIUtility.TrTextContent("Add Override"), EditorStyles.miniButton)) { var r = hscope.rect; var pos = new Vector2(r.x + r.width / 2f, r.yMax + 18f); FilterWindow.Show(pos, new VolumeComponentProvider(asset, this)); } } } }