protected override void OnDrawRowItem(Rect rect, GridViewData itemData) { Rect drawRect = rect; if (ShowSeparator) { drawRect.height -= SEPARATOR_LINE_HEIGHT; } EditorGUI.LabelField(drawRect, itemData.DisplayName); drawRect.y += drawRect.height; drawRect.height = SEPARATOR_LINE_HEIGHT; EGUI.DrawHorizontalLine(drawRect); }
protected override void RowGUI(RowGUIArgs args) { Rect rect = args.rowRect; SimpleListTreeViewItem <T> viewItem = args.item as SimpleListTreeViewItem <T>; if (listView.ShowSeparator) { rect.height -= 6.0f; } if (listView.OnDrawItem == null) { EditorGUI.LabelField(rect, viewItem.displayName); } else { listView.OnDrawItem(rect, viewItem.id); } if (listView.ShowSeparator) { EGUI.DrawHorizontalLine(new Rect(rect.x, rect.y + rect.height, rect.width, 6.0f)); } }
private ReorderableList CreateRList(GUIContent titleContent, NodeType nodeType, List <NodeData> datas) { bool isEditable = nodeType == NodeType.BindNode; ReorderableList reorderableList = new ReorderableList(datas, typeof(NodeData), isEditable, true, isEditable, isEditable); reorderableList.elementHeight = EditorGUIUtility.singleLineHeight * 3; reorderableList.drawHeaderCallback = (rect) => { EditorGUI.LabelField(rect, titleContent, EGUIStyles.BoldLabelStyle); }; reorderableList.drawElementCallback = (rect, index, isActive, isFocused) => { Rect indexRect = new Rect(rect); indexRect.width = Styles.IndexRectWidth; EditorGUI.LabelField(indexRect, "" + index); Rect contentRect = new Rect(rect.x + Styles.IndexRectWidth, rect.y, rect.width - Styles.IndexRectWidth - Styles.CheckRectWidth, EditorGUIUtility.singleLineHeight); NodeData data = datas[index]; if (nodeType == NodeType.BindNode) { data.name = EditorGUI.TextField(contentRect, Contents.NameContent, data.name); } else { EditorGUI.TextField(contentRect, Contents.NameContent, data.name); } contentRect.y += contentRect.height; if (nodeType == NodeType.SMRendererNode) { EditorGUI.ObjectField(contentRect, Contents.RendererContent, data.renderer, typeof(SkinnedMeshRenderer), true); } else if (nodeType == NodeType.BoneNode) { EditorGUI.ObjectField(contentRect, Contents.TransformContent, data.transform, typeof(Transform), true); } else if (nodeType == NodeType.BindNode) { data.transform = (Transform)EditorGUI.ObjectField(contentRect, Contents.TransformContent, data.transform, typeof(Transform), true); } Rect checkRect = new Rect(contentRect.x + contentRect.width, rect.y, Styles.CheckRectWidth, Styles.CheckRectWidth); string errorTips = string.Empty; bool isValid = (from d in datas where d.name == data.name select d).ToArray().Length == 1; if (isValid) { isValid = (nodeType == NodeType.SMRendererNode) ? data.renderer != null : data.transform != null; if (!isValid) { errorTips = Contents.ContentIsNull; } } else { errorTips = Contents.NameRepeatStr; } if (!isValid) { if (GUI.Button(checkRect, new GUIContent(EGUIResources.ErrorIcon, errorTips))) { EditorUtility.DisplayDialog("Error", errorTips, "OK"); } } contentRect.y += contentRect.height; EGUI.DrawHorizontalLine(contentRect); }; reorderableList.onAddCallback = (list) => { NodeData data = new NodeData() { nodeType = nodeType, }; datas.Add(data); }; return(reorderableList); }
public void OnGUILayout() { if (direction == DragLineDirection.Horizontal) { if (position.height < 2.0f) { position.height = 2.0f; } if (LowLimitXY > 0.0f && position.y < LowLimitXY) { position.y = LowLimitXY; } else if (UpperLimitXY > 0.0f && position.y + position.height > UpperLimitXY) { position.y = UpperLimitXY - position.height; } EGUI.DrawHorizontalLine(position, Color.grey); EditorGUIUtility.AddCursorRect(position, MouseCursor.ResizeVertical); } else if (direction == DragLineDirection.Vertical) { if (position.width < 2.0f) { position.width = 2.0f; } if (LowLimitXY > 0.0f && position.x < LowLimitXY) { position.x = LowLimitXY; } else if (UpperLimitXY > 0.0f && position.x + position.width > UpperLimitXY) { position.x = UpperLimitXY - position.width; } EGUI.DrawVerticalLine(position, Color.grey); EditorGUIUtility.AddCursorRect(position, MouseCursor.ResizeHorizontal); } if (Event.current != null) { if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && position.Contains(Event.current.mousePosition)) { isDragging = true; Event.current.Use(); } else if (isDragging && Event.current.type == EventType.MouseDrag) { if (direction == DragLineDirection.Horizontal) { position.y += Event.current.delta.y; } else if (direction == DragLineDirection.Vertical) { position.x += Event.current.delta.x; } window.Repaint(); } else if (isDragging && Event.current.type == EventType.MouseUp) { isDragging = false; Event.current.Use(); } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Rect propertyDrawRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); bool isArrayElement = property.IsArrayElement(); if (!isArrayElement) { EditorGUI.LabelField(propertyDrawRect, label); propertyDrawRect.y += propertyDrawRect.height; propertyDrawRect.x += 40; propertyDrawRect.width -= 40; } SerializedProperty nameProperty = property.FindPropertyRelative("name"); EditorGUI.PropertyField(propertyDrawRect, nameProperty); propertyDrawRect.y += propertyDrawRect.height; SerializedProperty typeProperty = property.FindPropertyRelative("paramType"); EditorGUI.PropertyField(propertyDrawRect, typeProperty); LuaParamType paramType = (LuaParamType)typeProperty.intValue; propertyDrawRect.y += propertyDrawRect.height; if (paramType == LuaParamType.Integer) { SerializedProperty valueProperty = property.FindPropertyRelative("intValue"); EditorGUI.PropertyField(propertyDrawRect, valueProperty); } else if (paramType == LuaParamType.Float) { SerializedProperty valueProperty = property.FindPropertyRelative("floatValue"); EditorGUI.PropertyField(propertyDrawRect, valueProperty); } else if (paramType == LuaParamType.String) { SerializedProperty valueProperty = property.FindPropertyRelative("strValue"); EditorGUI.PropertyField(propertyDrawRect, valueProperty); } else if (paramType == LuaParamType.UObject) { SerializedProperty gObjectProperty = property.FindPropertyRelative("gObject"); EditorGUI.PropertyField(propertyDrawRect, gObjectProperty); SerializedProperty uObjectProperty = property.FindPropertyRelative("uObject"); if (gObjectProperty.objectReferenceValue == null) { uObjectProperty.objectReferenceValue = null; } else { if (uObjectProperty.objectReferenceValue == null) { uObjectProperty.objectReferenceValue = gObjectProperty.objectReferenceValue; } EditorGUI.BeginDisabledGroup(true); { propertyDrawRect.y += propertyDrawRect.height; EditorGUI.PropertyField(propertyDrawRect, uObjectProperty); } EditorGUI.EndDisabledGroup(); List <string> names = new List <string>(); List <UnityObject> objects = new List <UnityObject>(); names.Add("GameObject"); objects.Add(gObjectProperty.objectReferenceValue); GameObject gObject = (GameObject)gObjectProperty.objectReferenceValue; Component[] gComponents = gObject.GetComponents <Component>(); foreach (var c in gComponents) { names.Add(c.GetType().Name); objects.Add(c); } propertyDrawRect.y += propertyDrawRect.height; uObjectProperty.objectReferenceValue = EGUI.DrawPopup <UnityObject>(propertyDrawRect, "Component", names.ToArray(), objects.ToArray(), uObjectProperty.objectReferenceValue); } } if (isArrayElement) { propertyDrawRect.y += propertyDrawRect.height; EGUI.DrawHorizontalLine(propertyDrawRect); } }