/// <summary> /// Draws the panel contents /// </summary> /// <returns>The rect for the entire OnGUI panel drawing.</returns> public virtual void OnGUI() { if (!DrawAsWindow) { EditorGUIUtils.DrawSplitter(); } }
void OnGUI() { if (!MARSEntitlements.instance.EntitlementsCheckGUI(position.width)) { return; } if (EditorApplication.isPlayingOrWillChangePlaymode && !Application.isPlaying) { GUIUtility.ExitGUI(); } var headerToggle = MarsEditorGUI.Styles.HeaderToggle; var headerLabel = MarsEditorGUI.Styles.HeaderLabel; using (var outerArea = new EditorGUILayout.VerticalScope(GUIStyle.none)) { using (var scrollView = new EditorGUILayout.ScrollViewScope(m_ScrollView)) { using (var innerArea = new EditorGUILayout.VerticalScope(GUIStyle.none)) { if (Event.current.type == EventType.Repaint) { m_VerticalScrollActive = outerArea.rect.height <= innerArea.rect.height; m_HorizontalScrollActive = outerArea.rect.width <= innerArea.rect.width; } EditorGUIUtils.DrawSplitter(); foreach (var panelView in m_PanelViews) { var drawAsWindow = DrawAsWindow(panelView); var panelExpanded = panelView.PanelExpanded; panelExpanded = EditorGUIUtils.DrawFoldoutUI( panelExpanded && !drawAsWindow, !drawAsWindow, panelView.PanelLabel, headerToggle, headerLabel, panelView.OnGUI, panelView.RecordFoldoutAnalyticsEvent, panelView.HelpButtonAction, panelView.SettingsButtonFunc, panelView.TabMenuFunc); // Don't want to set panel these values if not the parent of the panel if (!drawAsWindow) { panelView.PanelExpanded = panelExpanded; panelView.ScrollingVertical = m_VerticalScrollActive; panelView.ScrollingHorizontal = m_HorizontalScrollActive; } } } m_ScrollView = scrollView.scrollPosition; } } }
// ReSharper disable once MemberCanBePrivate.Global public static bool DrawAvatarFoldout(SerializedProperty avatar, BoneWrapper[] bones, ref bool showBodyPicker, bool forceDrawing = false) { if (!forceDrawing) { if (avatar.objectReferenceValue == null) { return(false); } if (!((Avatar)avatar.objectReferenceValue).isHuman) { return(false); } } EditorGUIUtils.DrawSplitter(); if (EditorGUIUtils.DrawHeaderWithFoldout(bodyLabel, showBodyPicker)) { showBodyPicker = !showBodyPicker; } if (showBodyPicker) { using (new EditorGUILayout.VerticalScope("TE NodeBackground")) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); Rect rect = GUILayoutUtility.GetRect(Silhouettes[bodyView], GUIStyle.none, GUILayout.MaxWidth(Silhouettes[bodyView].image.width)); DrawBodyParts(rect, bodyView); bool hasHover = false; if (bones != null) { for (int i = 0; i < bones.Length; i++) { hasHover |= DrawBone(bodyView, i, rect, bones[i], hasHover); } } GUILayout.FlexibleSpace(); } Rect lastRect = GUILayoutUtility.GetLastRect(); lastRect.x += 5f; lastRect.width = 80f; lastRect.yMin = lastRect.yMax - 69f; lastRect.height = 16f; for (int j = 0; j < toggleStrings.Length; j++) { if (GUI.Toggle(lastRect, bodyView == j, toggleStrings[j], EditorStyles.miniButton)) { bodyView = j; } lastRect.y += 16f; } } } EditorGUIUtils.DrawSplitter(); return(true); }
protected override void Draw() { if (m_SimView == null || m_SimView.SceneType == ViewSceneType.None) { return; } using (new EditorGUILayout.VerticalScope(Styles.AreaAlignmentLargeMargin)) { SimulationControlsGUI.ViewSelectionElement(m_SimView, m_Contents); EditorGUIUtils.DrawSplitter(); SimulationControlsGUI.DrawControlsWindow(false); } }
public override void OnInspectorGUI() { serializedObject.UpdateIfRequiredOrScript(); if (type == null) { EditorGUILayout.HelpBox("The type associated with this Asset List could not be found.", MessageType.Error); EditorGUILayout.PropertyField(typeString); serializedObject.ApplyModifiedProperties(); return; } using (new EditorGUI.DisabledScope(typeIsAsset)) { //Force assets to only display as InAssets. if (typeIsAsset && assetType.intValue != 0) { assetType.intValue = 0; } EditorGUILayout.PropertyField(assetType); } using (var cCS = new EditorGUI.ChangeCheckScope()) { referenceObject = EditorGUILayout.ObjectField(referenceObjectLabel, referenceObject, type, true, singleHeight); if (cCS.changed) { if (referenceObject != null) { CreatePropertyDropdown(); } } } if (EditorGUIUtils.DrawHeaderWithFoldout(preferencesLabel, missingPropertyDisplay.isExpanded, headerXOffset: -16f)) { missingPropertyDisplay.isExpanded = !missingPropertyDisplay.isExpanded; } if (missingPropertyDisplay.isExpanded) { EditorGUILayout.PropertyField(missingPropertyDisplay); EditorGUILayout.PropertyField(additionalColumns); } EditorGUIUtils.DrawSplitter(); GUILayout.Space(8); using (new EditorGUIUtils.ContainerScope(columnsLabel, -2)) using (new EditorGUIUtils.OutlineScope(false, false)) { //Icon Header GUILayout.Label(iconLabel, EditorGUIUtils.CenteredMiniLabel); if (typeIsTextureOrSprite) { EditorGUILayout.HelpBox("Type inherits from Texture or Sprite. Icon is automated.", MessageType.Info); } else { //Icon property path if (!string.IsNullOrEmpty(iconPropertyPath.stringValue)) { EditorGUILayout.PropertyField(iconPropertyPath, GUIContent.none); } if (ValidateReferenceObjectWithHelpWarning(referenceObject)) { //Icon property button. Rect rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); rect.height = EditorGUIUtility.singleLineHeight; //this is required to fix issues with the Layout stage rect.xMin += EditorGUI.indentLevel * 15; if (GUI.Button(rect, findIconLabel)) { CreateIconPropertyDropdown(); iconPropertyDropdown?.Show(rect); } bool isArray = iconIsArray.boolValue; if (isArray) { float yBefore = rect.yMax; ArrayDataDrawer.OnGUI(ref rect, iconPropertyPath, iconArrayPropertyInformation, referenceObject, typeStrings, rect.x - 2); GUILayoutUtility.GetRect(0, rect.yMax - yBefore); } } } GUILayout.Space(6); EditorGUIUtils.DrawSplitter(alignXMinToZero: false); GUILayout.Space(4); GUILayout.Label(propertyLabel, EditorGUIUtils.CenteredMiniLabel); using (new EditorGUI.DisabledScope(true)) EditorGUILayout.TextField(titleLabel, "Name"); EditorGUILayout.PropertyField(nameDisplay); } reorderableList.DoLayoutList(); using (new EditorGUIUtils.OutlineScope()) { GUILayout.Label(searchlabel, EditorStyles.boldLabel); if (ValidateReferenceObjectWithHelpWarning(referenceObject)) { Rect rect = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight); if (GUI.Button(rect, addLabel)) { if (propertyDropdown == null) { CreatePropertyDropdown(); } propertyDropdown.Show(rect); } } } serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Draws the component editors in an inspector. /// </summary> public void OnGUI() { if (m_ComponentList == null) { return; } if (m_ComponentList.isDirty) { RefreshEditors(); m_ComponentList.isDirty = false; } var isEditable = !UnityEditor.VersionControl.Provider.isActive || AssetDatabase.IsOpenForEdit(m_ComponentList.self, StatusQueryOptions.UseCachedIfPossible); if (!targetRequiresProxyMenu) { m_MarsInspectorSharedSettings.ComponentTabSelection = 0; } using (new EditorGUI.DisabledScope(!isEditable)) { EditorGUILayout.LabelField(EditorGUIUtils.GetContent("Components"), EditorStyles.boldLabel); var availableWidth = EditorGUIUtility.currentViewWidth; var isWideEnoughForAllTabs = availableWidth > k_MinWidthForAllTabs; if (isWideEnoughForAllTabs && targetRequiresProxyMenu) { m_MarsInspectorSharedSettings.ComponentTabSelection = GUILayout.Toolbar(m_MarsInspectorSharedSettings.ComponentTabSelection, k_ProxyComponentsStrings); } else if (targetRequiresProxyMenu) { var tabIndex = m_MarsInspectorSharedSettings.ComponentTabSelection; var shortIndex = (tabIndex == 0) ? 0 : 1; k_ProxyFilterStrings[1] = ((tabIndex == 0) ? k_ProxyFilter : k_ProxyComponentsStrings[tabIndex]) + k_DownArrowPostFix; using (var check = new EditorGUI.ChangeCheckScope()) { var selectedShortIndex = GUILayout.Toolbar(shortIndex, k_ProxyFilterStrings); if (shortIndex != selectedShortIndex) { if (selectedShortIndex == 0) { m_MarsInspectorSharedSettings.ComponentTabSelection = 0; } else { ComponentFilterContextMenu(); } } else if (check.changed) { ComponentFilterContextMenu(); } } } if (targetRequiresProxyMenu && (MarsInspectorSharedSettings.Instance.ComponentTabSelection == k_ForcesTab)) { Forces.EditorExtensions.ForcesMenuItemsRegions.DrawForcesInInspectorForMainProxy(m_BaseEditor.target); } // Override list for (var i = 0; i < m_Editors.Count; i++) { var editor = m_Editors[i]; if (editor.activeProperty.serializedObject.targetObject == null) { continue; } if (CanDrawSelectedOption(editor.target)) { var title = string.Format("{0}|{1}", editor.GetDisplayTitle(), editor.GetToolTip()); var id = i; // Needed for closure capture below EditorGUIUtils.DrawSplitter(); var displayContent = EditorGUIUtils.DrawHeader( title, editor.baseProperty, editor.activeProperty, () => ResetComponent(editor.target.GetType(), id), () => RemoveComponent(id), () => CopyComponent(id), () => PasteComponent(id), CanPasteComponent(id), editor.HasDisplayProperties() ); if (displayContent) { if (beforeDrawComponentInspector != null) { beforeDrawComponentInspector(editor); } using (new EditorGUI.DisabledScope(!editor.activeProperty.boolValue)) { editor.OnInternalInspectorGUI(); } if (afterDrawComponentInspector != null) { afterDrawComponentInspector(editor); } } } } if (targetRequiresProxyMenu || (m_BaseEditor.target is ProxyGroup)) { if (m_Editors.Count > 0) { EditorGUIUtils.DrawSplitter(); EditorGUILayout.Space(); } AddComponentMenuButton(); EditorGUILayout.Space(); } } }