private void CreateContentRects(GUIStyle style, int indentLevel, out GUIContentRect nodeGUI, out GUIContentRect foldoutGUI, out GUIContentRect iconGUI, out GUIContentRect labelGUI) { GUIContent iconContent, labelContent; var foldoutContent = GetFoldoutContent(indentLevel); GetObjectNodeContents(_objectNode, out iconContent, out labelContent); nodeGUI = new GUIContentRect(GUIContent.none, GUILayoutUtility.GetRect(foldoutContent, style)); foldoutGUI = new GUIContentRect(foldoutContent, nodeGUI); iconGUI = new GUIContentRect(iconContent, nodeGUI); labelGUI = new GUIContentRect(labelContent, nodeGUI); foldoutGUI.SetWidth(InterfaceableGUIHelper.GetMinWidth(foldoutContent, style) + 2.0f); iconGUI.MoveNextTo(foldoutGUI); iconGUI.SetWidth(iconContent == null ? 0.0f : (InterfaceableGUIHelper.GetScaledTextureWidth(iconContent.image, foldoutGUI.Rect.height, style) + 2.0f)); labelGUI.MoveNextTo(iconGUI); labelGUI.SetWidth(InterfaceableGUIHelper.GetMinWidth(labelContent, style)); }
private static void DrawField(SerializedContainer serializedContainer, Rect rect, bool pingable) { var buttonId = GUIUtility.GetControlID(FocusType.Passive) + 1; if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) { if (pingable) { InterfaceableGUIHelper.PingObject(serializedContainer.ObjectField); } } var pinging = GUIUtility.hotControl == buttonId && pingable; GUIStyle style; if (serializedContainer.Dropping) { style = InterfaceableGUIHelper.InspectorStyles.DropBox; } else if (pinging) { style = InterfaceableGUIHelper.InspectorStyles.Pinging; } else if (serializedContainer.Selecting) { style = InterfaceableGUIHelper.InspectorStyles.Selecting; } else { style = InterfaceableGUIHelper.InspectorStyles.Result; } if (serializedContainer.ObjectFieldProperty.hasMultipleDifferentValues || serializedContainer.ObjectField == null) { style.alignment = TextAnchor.MiddleCenter; style.imagePosition = ImagePosition.TextOnly; } else { style.alignment = TextAnchor.MiddleLeft; style.imagePosition = ImagePosition.ImageLeft; } GUI.Label(rect, GUIContent.none, style); GUIContentRect icon, label; serializedContainer.GetContainerContents(rect, serializedContainer.Dropping, out icon, out label); style.normal.background = null; if (icon.Content != null) { icon.SetWidth(InterfaceableGUIHelper.GetScaledTextureWidth(icon.Content.image, rect.height + 2.0f)); label.MoveNextTo(icon, -3.0f); GUI.Label(icon, icon, style); } GUI.Label(label, label, style); if (!SerializedContainer.AnyDropping && pingable) { EditorGUIUtility.AddCursorRect(rect, MouseCursor.Zoom); } }