public void Draw(TUIState s, TData p, Editor owner) { var r = m_IsExpanded(s, p, owner); CoreEditorUtils.DrawSplitter(boxed); r.target = CoreEditorUtils.DrawHeaderFoldout(m_Title, r.target, boxed); // We must start with a layout group here // Otherwise, nested FadeGroup won't work GUILayout.BeginVertical(); if (animate && EditorGUILayout.BeginFadeGroup(r.faded) || !animate && r.target) { if (indent) { ++EditorGUI.indentLevel; } for (var i = 0; i < m_Bodies.Length; i++) { m_Bodies[i].Draw(s, p, owner); } if (indent) { --EditorGUI.indentLevel; } } if (animate) { EditorGUILayout.EndFadeGroup(); } GUILayout.EndVertical(); }
/// <summary> Create an IDrawer foldout header using an ExpandedState </summary> /// <param name="title">Title wanted for this foldout header</param> /// <param name="mask">Bit mask (enum) used to define the boolean saving the state in ExpandedState</param> /// <param name="state">The ExpandedState describing the component</param> /// <param name="contentDrawer">The content of the foldout header</param> public static IDrawer FoldoutGroup <TEnum, TState>(string title, TEnum mask, ExpandedState <TEnum, TState> state, params ActionDrawer[] contentDrawer) where TEnum : struct, IConvertible { return(Action((uiState, data, editor) => { CoreEditorUtils.DrawSplitter(); bool expended = state[mask]; bool newExpended = CoreEditorUtils.DrawHeaderFoldout(title, expended); if (newExpended ^ expended) { state[mask] = newExpended; } if (newExpended) { ++EditorGUI.indentLevel; for (var i = 0; i < contentDrawer.Length; i++) { contentDrawer[i](uiState, data, editor); } --EditorGUI.indentLevel; EditorGUILayout.Space(); } })); }
public override void OnInspectorGUI() { serializedObject.Update(); if (actualTarget.isDirty) { RefreshEditors(); actualTarget.isDirty = false; } using (var vscope = new EditorGUILayout.VerticalScope()) { EditorGUILayout.PropertyField(m_IsGlobal); if (!m_IsGlobal.boolValue) // Blend radius is not needed for global volumes { EditorGUILayout.PropertyField(m_BlendRadius); m_BlendRadius.floatValue = Mathf.Max(m_BlendRadius.floatValue, 0f); } EditorGUILayout.PropertyField(m_Weight); EditorGUILayout.PropertyField(m_Priority); EditorGUILayout.Space(); // 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("No override set on this volume. Drop a component here or use the Add button.", MessageType.Info); } EditorGUILayout.Space(); using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(CoreEditorUtils.GetContent("Add component overrides..."), EditorStyles.miniButton)) { var r = hscope.rect; var pos = new Vector2(r.x + r.width / 2f, r.yMax + 18f); FilterWindow.Show(pos, new VolumeComponentProvider(actualTarget, this)); } } EditorGUILayout.Space(); // Handle components drag'n'drop var e = Event.current; if (e.type == EventType.DragUpdated) { if (IsDragValid(vscope.rect, e.mousePosition)) { DragAndDrop.visualMode = DragAndDropVisualMode.Link; e.Use(); } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } else if (e.type == EventType.DragPerform) { if (IsDragValid(vscope.rect, e.mousePosition)) { DragAndDrop.AcceptDrag(); var objs = DragAndDrop.objectReferences; foreach (var o in objs) { var compType = ((MonoScript)o).GetClass(); AddComponent(compType); } e.Use(); } } } serializedObject.ApplyModifiedProperties(); }
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("No override set on this volume. Drop a component here or use the Add button.", MessageType.Info); } EditorGUILayout.Space(); using (var hscope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button(CoreEditorUtils.GetContent("Add component overrides..."), 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)); } } } }