protected override void OnGUI(Rect position, GUIContent label) { position = BeginBlock(metadata, position, label); T newValue; var oldValue = Convert.ToInt32(metadata.value); var fieldPosition = new Rect ( position.x, position.y, position.width, EditorGUIUtility.singleLineHeight ); if (metadata.HasAttribute <InspectorRangeAttribute>()) { var rangeAttribute = metadata.GetAttribute <InspectorRangeAttribute>(); newValue = (T)Convert.ChangeType(EditorGUI.IntSlider(fieldPosition, oldValue, (int)rangeAttribute.min, (int)rangeAttribute.max), typeof(T)); } else { newValue = (T)Convert.ChangeType(LudiqGUI.DraggableIntField(fieldPosition, oldValue), typeof(T)); } if (EndBlock(metadata)) { metadata.RecordUndo(); metadata.value = newValue; } }
protected override void OnControlGUI(Rect position) { EditorGUI.BeginChangeCheck(); T newValue; var oldValue = Convert.ToInt32(accessor.value); if (rangeAttribute != null) { newValue = (T)Convert.ChangeType(EditorGUI.IntSlider(position, oldValue, (int)rangeAttribute.min, (int)rangeAttribute.max), typeof(T)); } else { newValue = (T)Convert.ChangeType(LudiqGUI.DraggableIntField(position, oldValue), typeof(T)); } if (EditorGUI.EndChangeCheck()) { accessor.RecordUndo(); accessor.value = newValue; } }