public override Vector2 GetWindowSize() { var size = base.GetWindowSize(); size.y = 10.0f; // padding size.y += RectHelper.LineHeight; // name size.y += ValueDefinitionControl.GetHeight(_definition, VariableInitializerType.None, null, false); size.y += RectHelper.LineHeight; // button return(size); }
public override void OnGUI(Rect position) { var rect = RectHelper.Inset(position, 5.0f); var nameRect = RectHelper.TakeLine(ref rect); var buttonRect = RectHelper.TakeTrailingHeight(ref rect, EditorGUIUtility.singleLineHeight); RectHelper.TakeTrailingHeight(ref rect, RectHelper.VerticalSpace); var isExpanded = false; _name = EditorGUI.TextField(nameRect, _name); _definition = ValueDefinitionControl.Draw(rect, GUIContent.none, _definition, VariableInitializerType.None, null, false, ref isExpanded); if (GUI.Button(buttonRect, "Apply")) { _control.ApplyDefinition(_index, _name, _definition); editorWindow.Close(); } }
private void DrawDefinition(Rect rect, IList list, int index) { var property = _definitions.GetArrayElementAtIndex(index); var expanded = property.isExpanded; using (var changes = new EditorGUI.ChangeCheckScope()) { var schema = _schema[index]; var definition = ValueDefinitionControl.Draw(rect, new GUIContent(schema.Name), schema.Definition, _schema.InitializerType, _schema.Tags, true, ref expanded); if (changes.changed) { _schema[index] = new VariableDefinition { Name = schema.Name, Definition = definition } } ; } property.isExpanded = expanded; }
private float GetDefinitionHeight(int index) { var property = _definitions.GetArrayElementAtIndex(index); return(ValueDefinitionControl.GetHeight(_schema[index].Definition, _schema.InitializerType, _schema.Tags, property.isExpanded)); }