private void DrawInfos() { if (this.serializationInfoTree == null) { return; } if (this.noteStyle == null) { this.noteStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel); this.noteStyle.active.textColor = this.noteStyle.normal.textColor; this.noteStyle.onActive.textColor = this.noteStyle.normal.textColor; this.noteStyle.onFocused.textColor = this.noteStyle.normal.textColor; this.noteStyle.focused.textColor = this.noteStyle.normal.textColor; this.noteStyle.margin = new RectOffset(20, 4, 0, 4); this.noteStyle.padding = new RectOffset(0, 0, 0, 0); } if (this.serializationInfoTree.Selection.Count > 0) { var info = this.serializationInfoTree.Selection[0].Value as MemberSerializationInfo; GUILayout.Space(10); GUILayout.BeginHorizontal(); { var bgRect = GUIHelper.GetCurrentLayoutRect().Expand(0, 10); SirenixEditorGUI.DrawSolidRect(bgRect, SirenixGUIStyles.DarkEditorBackground); SirenixEditorGUI.DrawBorders(bgRect, 0, 0, 1, 0); // Note text. GUILayout.BeginVertical(GUILayoutOptions.MinHeight(80)); { foreach (var note in info.Notes) { Rect noteRect = GUILayoutUtility.GetRect(GUIHelper.TempContent(note), this.noteStyle); var dot = noteRect; dot.x -= 8; dot.y += 5; dot.height = 4; dot.width = 4; SirenixEditorGUI.DrawSolidRect(dot, EditorGUIUtility.isProSkin ? Color.white : Color.black); EditorGUI.SelectableLabel(noteRect, note, this.noteStyle); GUILayout.Space(4); } } GUILayout.EndVertical(); var r = GUIHelper.GetCurrentLayoutRect(); SirenixEditorGUI.DrawVerticalLineSeperator(r.x, r.y, r.height); } GUILayout.EndHorizontal(); GUILayout.Space(10); } }
/// <summary> /// Ends the cell. /// </summary> public void EndCell(int rowIndex) { var row = this.rows[rowIndex]; if (Event.current.type == EventType.Repaint) { var r = GUIHelper.GetCurrentLayoutRect(); row.tmpRowHeight = Mathf.Max(row.tmpRowHeight, (int)r.height); this.rows[rowIndex] = row; } GUILayout.EndVertical(); GUILayout.EndVertical(); }
private void DrawTopBar() { Rect rect = SirenixEditorGUI.BeginHorizontalToolbar(); { var iconRect = rect.AlignLeft(SerializationInfoMenuItem.IconSize).AlignMiddle(SerializationInfoMenuItem.IconSize); iconRect.x += SerializationInfoMenuItem.IconSpacing * 2; GUI.color = (this.backendFlags & SerializationBackendFlags.Odin) != 0 ? Color.white : new Color(1f, 1f, 1f, 0.2f); GUI.DrawTexture(iconRect.Padding(2), EditorIcons.OdinInspectorLogo, ScaleMode.ScaleToFit); iconRect.x += SerializationInfoMenuItem.IconSize + SerializationInfoMenuItem.IconSpacing * 2; GUI.color = (this.backendFlags & SerializationBackendFlags.Unity) != 0 ? Color.white : new Color(1f, 1f, 1f, 0.2f); GUI.DrawTexture(iconRect.Padding(2), EditorIcons.UnityLogo, ScaleMode.ScaleToFit); GUI.color = Color.white; var typeName = " " + (this.targetType == null ? "Select Type" : this.targetType.GetNiceName().SplitPascalCase()) + " "; GUILayout.Space(iconRect.xMax + 3); bool selectB = SirenixEditorGUI.ToolbarButton(new GUIContent(typeName)); GUILayout.FlexibleSpace(); bool selectA = SirenixEditorGUI.ToolbarButton(EditorIcons.TriangleDown); if (selectA || selectB) { var btnRect = GUIHelper.GetCurrentLayoutRect().HorizontalPadding(20).AlignTop(20); btnRect = btnRect.AlignRight(400); var source = AssemblyUtilities.GetTypes(AssemblyTypeFlags.CustomTypes) .Where(x => !x.IsAbstract && x.IsClass && x.InheritsFrom <UnityEngine.Object>()) .Where(x => !x.Assembly.FullName.StartsWith("Sirenix")) .OrderBy(x => x.Assembly.GetAssemblyTypeFlag()) .OrderBy(x => x.Assembly.GetAssemblyTypeFlag()) .ThenBy(x => x.Namespace) .ThenByDescending(x => x.Name); var p = new TypeSelector(source, false); p.SelectionChanged += (types) => { var t = types.FirstOrDefault(); if (t != null) { this.targetType = t; this.odinContext = this.targetType.IsDefined <ShowOdinSerializedPropertiesInInspectorAttribute>(true); this.CreateMenuTree(true); } }; p.SetSelection(this.targetType); p.ShowInPopup(300); } } SirenixEditorGUI.EndHorizontalToolbar(); }
/// <summary> /// Not yet documented. /// </summary> public static DropZoneHandle BeginDropZone(object key, Type type, bool canAcceptMove) { Update(); GUILayout.BeginVertical(); var rect = GUIHelper.GetCurrentLayoutRect(); var dropZoneHandle = GUIHelper.GetTemporaryContext <DropZoneHandle>(dropZoneKey, key).Value; dropZoneHandle.Type = type; dropZoneHandle.CanAcceptMove = canAcceptMove; dropZoneHandle.LayoutDepth = dropZoneHandles.Count; dropZoneHandles.Push(dropZoneHandle); dropZoneHandle.Update(EventType.Layout); dropZoneHandle.SourceWindow = GUIHelper.CurrentWindow; if (Event.current.type == EventType.Repaint) { dropZoneHandle.Rect = rect; } return(dropZoneHandle); }