protected bool DrawDisplayedToggle(Rect pos, SerializedProperty prop) { if (GUITools.IconButton(pos.x, pos.y, prop.isExpanded ? BuiltInIcons.GetIcon("animationvisibilitytoggleon", "Hide") : BuiltInIcons.GetIcon("animationvisibilitytoggleoff", "Show"), GUITools.white)) { prop.isExpanded = !prop.isExpanded; } return(prop.isExpanded); }
static void OnToolbarGUI() { if (Application.isPlaying) { return; } if (GUILayout.Button(BuiltInIcons.GetIcon("BuildSettings.SelectedIcon", "Open Build Options"), ToolbarExtender.commandButtonStyle)) { ProjectBuilderWindow.OpenWindow(); } }
protected void DrawAddElement(Rect pos, SerializedProperty prop, float indent1, bool displayedValue) { GUI.enabled = displayedValue; if (GUITools.IconButton(indent1, pos.y, BuiltInIcons.GetIcon("Toolbar Plus", "Add New Element"), displayedValue ? GUITools.green : GUITools.white)) { prop.InsertArrayElementAtIndex(prop.arraySize); SerializedProperty p = prop.GetArrayElementAtIndex(prop.arraySize - 1); if (p.propertyType == SerializedPropertyType.ObjectReference) { p.objectReferenceValue = null; } } GUI.enabled = true; }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { NeatArrayAttribute att = attribute as NeatArrayAttribute; int origIndentLevel = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; float indent1, indent2, indent2Width; bool displayedValue; string lbl = label.text; StartArrayDraw(pos, ref prop, out indent1, out indent2, out indent2Width, out displayedValue); if (att != null) { MakeSureSizeIsOK(prop, att.enforceSize); } if (att == null || att.enforceSize < 0) { DrawAddElement(pos, prop, indent1, displayedValue); } float xOffset = (att == null || att.enforceSize < 0 ? indent2 : indent1) + GUITools.toolbarDividerSize; // DrawArrayTitle ( pos, prop.arraySize, lbl, att != null ? att.tooltip : string.Empty, xOffset ); string tooltip = att != null ? att.tooltip : string.Empty; lbl += " [" + prop.arraySize + "] "; GUITools.Label(new Rect(xOffset, pos.y, pos.width, pos.height), new GUIContent(lbl), GUITools.black, GUITools.boldLabel); bool showsTooltip = false; if (displayedValue && !string.IsNullOrEmpty(tooltip)) { showsTooltip = true; GUIContent ttGUI = new GUIContent(tooltip); // float ttWidth = tooltipStyle.CalcSize(ttGUI).x; // GUITools.Label(new Rect(pos.x + pos.width - ttWidth, pos.y, ttWidth, pos.height), ttGUI, GUITools.black, tooltipStyle); GUITools.Label(new Rect(xOffset, pos.y + EditorGUIUtility.singleLineHeight, pos.width, pos.height), ttGUI, GUITools.black, tooltipStyle); } if (displayedValue) { int indexToDelete = -1; pos.x = xOffset; pos.y += GUITools.singleLineHeight * (showsTooltip ? 2 : 1); pos.width = indent2Width - GUITools.toolbarDividerSize * 2; pos.height = EditorGUIUtility.singleLineHeight; GUIContent deleteContent = BuiltInIcons.GetIcon("Toolbar Minus", "Delete Element"); for (int i = 0; i < prop.arraySize; i++) { if (att == null || att.enforceSize < 0) { if (GUITools.IconButton(indent1, pos.y, deleteContent, GUITools.red)) { indexToDelete = i; } } SerializedProperty p = prop.GetArrayElementAtIndex(i); EditorGUI.PropertyField(pos, p, GUITools.noContent, true); pos.y += EditorGUI.GetPropertyHeight(p, true); } if (indexToDelete != -1) { SerializedProperty p = prop.GetArrayElementAtIndex(indexToDelete); if (p.propertyType == SerializedPropertyType.ObjectReference) { if ((prop.objectReferenceValue) != null) { prop.DeleteArrayElementAtIndex(indexToDelete); } } prop.DeleteArrayElementAtIndex(indexToDelete); } } EditorGUI.indentLevel = origIndentLevel; }