How can i add a depth class to UL in a menu list? I try this code, but i get only the same default depth for all UL tags.

function MYTHEME_preprocess_menu_tree_override(&amp;$variables) {
  $variables['tree_raw'] = $variables['tree'];
}

function MYTHEME_menu_tree($variables) {
  $menu_level = isset($variables['tree_raw']['#depth']) ? $variables['tree_raw']['#depth'] : 1;
  $class = "menu menu-lvl-".$menu_level;
  return '&lt;ul class="menu clearfix'.$class.'"&gt;' . $variables['tree'] . '&lt;/ul&gt;';
}
For Drupal 7.

MYTHEME_menu_link(array $variables) {
  global $_current_menu_depth;
  $element = $variables['element'];
  $_current_menu_depth = $element['#original_link']['depth'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '&lt;li' . drupal_attributes($element['#attributes']) . '&gt;' . $output . $sub_menu . "&lt;/li&gt;\n";
}

function MYTHEME_menu_tree($variables) {
  global $_current_menu_depth;
  return '&lt;ul class="menu menu--'.$_current_menu_depth.'"&gt;' . $variables['tree'] . '&lt;/ul&gt;';
}


NOTE! I noticed this breaks in some cases. I had a three levels deep menu and the second level menu was marked as third.