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); }
protected bool DrawDisplayedToggle(Rect pos, SerializedProperty prop) { SerializedProperty displayed = prop.FindPropertyRelative(displayedName); if (GUITools.IconButton(pos.x, pos.y, displayed.boolValue ? isShownContent : hiddenContent, GUITools.white)) { displayed.boolValue = !displayed.boolValue; } return(displayed.boolValue); }
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; }
void DrawName(string current, GUIContent gui, OnAssetsLoaded onAssetsLoaded, Func <List <Object>, List <Object> > onAssetsFound, Action <string> onPicked) { EditorGUILayout.BeginHorizontal(); DrawLabel(gui); if (GUITools.Button(GetGUI(current), GUITools.popup)) { BuildMenu(current, onAssetsLoaded, onAssetsFound, onPicked, (e) => e.assetName); } if (GUITools.IconButton(pingGUI)) { PingAssetWithName(current, onAssetsLoaded, onAssetsFound); } EditorGUILayout.EndHorizontal(); }
void DrawName(Rect pos, string current, GUIContent gui, OnAssetsLoaded onAssetsLoaded, Func <List <Object>, List <Object> > onAssetsFound, Action <string> onPicked) { float x = pos.x; DrawLabel(ref x, pos.y, gui); if (DrawButton(x, pos, GetGUI(current))) { BuildMenu(current, onAssetsLoaded, onAssetsFound, onPicked, (e) => e.assetName); } if (GUITools.IconButton(pos.x + (pos.width - GUITools.iconButtonWidth), pos.y, pingGUI)) { PingAssetWithName(current, onAssetsLoaded, onAssetsFound); } }
void Draw(Object current, GUIContent gui, OnAssetsLoaded onAssetsLoaded, Func <List <Object>, List <Object> > onAssetsFound, Action <Object> onPicked) { EditorGUILayout.BeginHorizontal(); DrawLabel(gui); if (GUITools.Button(GetGUI(current), GUITools.popup)) { BuildMenu(current, onAssetsLoaded, onAssetsFound, onPicked, (e) => e.asset); } if (GUITools.IconButton(pingGUI)) { EditorGUIUtility.PingObject(current); } EditorGUILayout.EndHorizontal(); }
void Draw(Rect pos, Object current, GUIContent gui, OnAssetsLoaded onAssetsLoaded, Func <List <Object>, List <Object> > onAssetsFound, Action <Object> onPicked) { float x = pos.x; DrawLabel(ref x, pos.y, gui); if (DrawButton(x, pos, GetGUI(current))) { BuildMenu(current, onAssetsLoaded, onAssetsFound, onPicked, (e) => e.asset); } if (GUITools.IconButton(pos.x + (pos.width - GUITools.iconButtonWidth), pos.y, pingGUI)) { EditorGUIUtility.PingObject(current); } }
public Object Draw(Rect pos, Object current, GUIContent gui, Func <List <AssetSelectorElement>, List <AssetSelectorElement> > onAssetsLoaded) { float buttonStart = pos.width - GUITools.iconButtonWidth; //draw field int selected = EditorGUI.Popup(new Rect(pos.x, pos.y, buttonStart, pos.height), gui.text, GetActiveIndex(current), allNames); // draw reset button if (GUITools.IconButton(pos.x + buttonStart, pos.y, resetButtonContent, GUITools.white)) { UpdateAssetReferences(true, onAssetsLoaded); } return(selected < 0 ? null : elements[selected].asset); }
public Object Draw(Object current, GUIContent gui, Func <List <AssetSelectorElement>, List <AssetSelectorElement> > onAssetsLoaded) { EditorGUILayout.BeginHorizontal(); //draw field int selected = EditorGUILayout.Popup(gui, GetActiveIndex(current), allNames); // draw reset button if (GUITools.IconButton(resetButtonContent, GUITools.white)) { UpdateAssetReferences(true, onAssetsLoaded); } EditorGUILayout.EndHorizontal(); return(selected < 0 ? null : elements[selected].asset); }
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; }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { NeatArrayAttribute att = attribute as NeatArrayAttribute; float indent1, indent2, indent2Width; bool displayedValue; StartArrayDraw(pos, ref prop, ref label, 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, label, xOffset); if (displayedValue) { int indexToDelete = -1; pos.x = xOffset; pos.y += GUITools.singleLineHeight; pos.width = indent2Width - GUITools.toolbarDividerSize * 2; pos.height = EditorGUIUtility.singleLineHeight; 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, true); pos.y += EditorGUI.GetPropertyHeight(p, true); } if (indexToDelete != -1) { SerializedProperty p = prop.GetArrayElementAtIndex(indexToDelete); OnDeleteElement(p); if (p.propertyType == SerializedPropertyType.ObjectReference) { prop.DeleteArrayElementAtIndex(indexToDelete); } prop.DeleteArrayElementAtIndex(indexToDelete); } } EditorGUI.EndProperty(); }