Open Editor Preferences to a certain Section?

Hi all,

I know its allot of trouble to try and use reflection, but i was just wondering if its possible
to show the Preferences Window and select a specific Section to be displayed?

		if( GUILayout.Button( "Show 9 Slice Preferences" ) )
		{
			Assembly asm = Assembly.GetAssembly( typeof(EditorWindow) );
			Type T = asm.GetType( "UnityEditor.PreferencesWindow" );
			MethodInfo M = T.GetMethod( "ShowPreferencesWindow", BindingFlags.NonPublic | BindingFlags.Static );
			M.Invoke( null, null );

			BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic;
			FieldInfo field_m_Sections = T.GetField("m_Sections", flags);

			int nCount = 0;

			PropertyInfo piCount = field_m_Sections.GetType().GetProperty( "Count" );
			if (piCount != null)
			{
				object values = piCount.GetValue( T, null );
				if (values != null)
				{
					PropertyInfo valuesCountProperty = values.GetType().GetProperty("Count");
					//if (countProperty != null)
					//{
						nCount = (int)valuesCountProperty.GetValue( T, null );
					//}
				}
			}

			for (int i = 0; i < nCount; i++)
			{
				object section = (object) field_m_Sections.GetType().GetGenericArguments()[i];
				FieldInfo fi_content = section.GetType().GetField( "content" );

				GUIContent c = (GUIContent) fi_content.GetValue( null );

				if( c.text == "9 Slice" )
				{
					FieldInfo fi_m_SelectedSectionIndex = T.GetField( "m_SelectedSectionIndex", flags );
					fi_m_SelectedSectionIndex.SetValue( i, null );
					//this.m_RefreshCustomPreferences = true;
					break;
				}
			}		
		}

1495399--83787--$9U9pH3b.png

if worst comes to worst i guess i can just reuse the Preferences class and let the user pick which way to view them.

using UnityEditor;
using UnityEngine;
using System.Collections;

public class NineSlice_Preferences : EditorWindow
{
	private static bool prefsLoaded = false;
	public static string key_ImageFilterMode = "Image_Filter_Mode";
	public static FilterMode enum_Image_Filter_Mode = FilterMode.Point;

	public static void ShowWindow()
	{
		EditorWindow.GetWindow( typeof(NineSlice_Preferences), true, "9 Slice Preferences", true );
	}

	void OnGUI () {
		PreferencesGUI();
	}

	// can also view preferences via menus.  Edit -> Preferences... -> 9 Slice (user manually selects)
	[PreferenceItem( "9 Slice" )]
	static void PreferencesGUI ()
	{
		if (!prefsLoaded)
		{
			enum_Image_Filter_Mode = (FilterMode) EditorPrefs.GetInt( key_ImageFilterMode, (int) FilterMode.Point );
			prefsLoaded = true;
		}

		enum_Image_Filter_Mode = (FilterMode) EditorGUILayout.EnumPopup( key_ImageFilterMode.Replace("_", " "), enum_Image_Filter_Mode );
		
		if (GUI.changed)
		{
			EditorPrefs.SetInt( key_ImageFilterMode, (int) enum_Image_Filter_Mode );
			NineSlice_EditorWindow.prefs_ImageFilterMode_Changed = true;
		}
	}
}

and call it:

		if( GUILayout.Button( "Show 9 Slice Preferences" ) )
		{
			NineSlice_Preferences.ShowWindow();
		}